Content originally posted in LPCWare by capiman on Tue Nov 05 08:45:49 MST 2013
Hello wzq121381,
have you checked if UARTCount is incremented when a character was received?
Have you checked (or printed) bytes you have received? Are they correct?
One possible problem in your code is, when you receive one wrong character, e.g. at the beginning, you are out of sync.
Example:
UARTBuffer[0] gets filled with 0x55 (by error). Now you can send your packets as long as you want, you will never get back to control your LED.
Perhaps check byte by byte. Each time you receive a wrong byte (e.g. first byte is not 0x01), reset UARTCounter, so you are ready to receive a new packet.
Other way could be to use a timer. When you received no byte for x seconds, reset UARTCounter back to 0.
Best regards,
Martin