Content originally posted in LPCWare by arunkollam on Tue Jul 09 05:25:15 MST 2013
Hi
i am writing a program which receives 0x03 and 0x04 strings continusly via UART0 and sends to a device through UART1.The device responds with a 3 bit data for each command(0x03 and 0x04).
DEVICE-1 sends 0x03 =>uart0----- LPC1227-----UART1=>0x03 to the device2
DEVICE-2 sends 0x01 0x0c 0xff =>uart1----- LPC1227-----UART0=>0x01 0x0c 0xffto the device1
DEVICE-1 sends 0x04 =>uart0----- LPC1227-----UART1=>0x04 to the device2
DEVICE-2 sends 0x01 0x0c 0xff =>uart1----- LPC1227-----UART0=>0x01 0x0c 0xffto the device1
The first bit of the receving bit is a command and it should be always 0x01.
my problem is in receiving the 3 bit data , some times the device 2 will not send 3 bits of data insted it will send 1 or 2 bits and my getchar waits for receiving it and the program enter into a endless loop.so any one can help me in writing a timer which waits for receiving the data for 5 ms and after 5ms , if there is no data received restart or clear the uart buffer.