Hallo
Im using UART0 in the LPC2103. Im not using interrupt. I just pool the UART. It doesnt do anything else but wait for RX data. On my PC im sending the same 11 bytes over and over again. (Just for test)
On the LPC2103 im saving the recevied data in a buffer. But sometimes the buffer contains an invalid byte. It happen rarely (~1 out of 100 times?)
Its not the same index that has a bad byte every time. There are no error flags generated by the UART. I have tried it on two diffrent devices with the same result.
E.x Im sending: 0x5 0x1 0x40 0x15 0x0 0x0 0x0 0x0 0x0 0x0 0xC Receiving when the UART fails: 0x7 0x1 0x40 0x15 0x0 0x0 0x0 0x0 0x0 0x0 0xC
The error can be anywhere in the received data and any value...
Are there any known issues with the UART in the LPC2103? Im I handling something wrong?
Im using KEIL uVision 3.40 and running the UART at 57600 baud but see the same at other baud rates. I even has a 5 ms delay between every bytes send from the PC, incase the LPC2103 cant keep up.
UART init:
// Enable RxD0 and TxD0 PINSEL0 &= 0xFFFFFFF5; PINSEL0 |= 0x00000005; // DLAB == 1 in order to get access to the DLL register U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit U0DLL = 38; //57600 // DLAB == 0 to lock the DLL register acess U0LCR = 0x03; // Enable FIFO U0FCR = 0x07;
The UART read function. The byte is returned and saved in the buffer
int getbyte (char* cData) { BYTE LSRValue = U0LSR; // Any errors?? if ( LSRValue & LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) ) { // Dummy read to clear *cData = U0RBR; LSRValue = U0LSR; U0FCR |= 0x02; // Reset RX fifo ulErrors++; // Just for testing return 0; // Error } if ( LSRValue & LSR_RDR ) { *cData = U0RBR; // Get data return 1;// Ok } // Nothing to read return 0; }