I have a project need controlled 74hc595 by serial port send command such as send"0xEA 0xFC 0x01 55"controlled Q0,and send"0xEA 0xFC 0x02 55"controlled Q1,
but i have a problem when i send first command is right,then send second command or third command MCU was stuck,as snapshot,who can help me fixed it ,thanks in advance!
but you do not check that "rxcount" has got bigger than 3. Remember you need a zero at the end of the characters to mark the end of the data so "buf" has to be at least one character bigger than your expected input.
There should be something to reset "rxcount" to zero again (maybe "rxcount = 0; buff[0] = 0;") when you have finished processing it.
I can help you with your project. You really need to use a delimiter at the end of each UART command transmission which controls the output of the 74HC595. A 0x0D delimeter will be fine. If you use delimiters like '\r\ or '\n' that is ENTER key then Proteus Virtual Terminal will not handle it and it will not send those characters to your PIC.
It is better if you can use COMPIM model without MAX232 in Proteus and link Proteus with any Serial Terminal software which can send delimiters like '\r' or '\n' at the end of each 4-byte command that you are using.
I will check your code today but I can't help much with MPLAB Hi-Tech PICC code because it is very old and I don't have it installed.
Tell me which delimiter you can use at the end of your 4-byte commands and I will tell you how to fix the code.
Once the end delimiter is received or if the byte lenght exceeds your 4-byte command then you have to reset the buffer index to 0 and set a flag which will be tested for true in the main loop and HC595 controlled in the main loop and then flag creared so that UART can receive new commands after processing the previous one.