I'm interfacing GPS module with LPC2378. The GPS module is sending data continuously and the packet size is more than 100 bytes. The receiver buffer's(RBR) size is 16 bytes. As soon as GPS module is connected to LPC's UART, the first 16 bytes are placed in RBR and the remaining bytes of GPS module is lost. The LSR(Line Status Register) shows overrun error. I tried using interrupts whenever ready data is available in RX line. But even in this case, LSR shows overrun error. How to receive all the bytes from GPS module in LPC2378 without overrun error?
Simple. Read the data from the UART faster than it is going in.
Then you did it wrong!
As Polly Kar said, it is very simple: you just need to ensure that you read the data from the UART faster than it is going in.
It seems unlikely that a "GPS module" would deliver data faster than a 72MHz ARM7 can read it - so the problem must be with your code.
This has nothing specifically to do with Keil.
For details of how to make optimum use of the LPC2378's features, consult the manufacturer's documentation, and look for Application Reports, examples etc on their website:
www.nxp.com/.../arm7-with-512kb-flash-58-kb-sram-ethernet-usb-2.0-device-can-and-10-bit-adc:LPC2378FBD144
GPS module is communicating at 9600 baud rate. Hence, UART1 is used with baud rate of 9600. The RBR is read continuously in an infinite loop. Still there is overrun error. Can you please let me know if there is any flaw in this logic? If yes, how do I resolve this? Below is the code
#include <lpc23xx.h> #include <stdint.h>
char ch; int main() { PINSEL0 |= 0x40000000; /* Enable TxD1 pin */ PINSEL1 |= 0x00000001; /* Enable RxD1 pin */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLM = 0x00; U1DLL = 78; /* 9600 Baud Rate @ 12MHz Clock */ U1LCR = 0x03; /* DLAB = 0 */ U1FCR = 0x07; /*Enable FIFO */
while(1)
{
if (U1LSR & 0x01) /* Check if data is ready in RBR */
ch=U1RBR; /*Read receiver buffer*/
}
Please read the instructions on how to post source code.
See: www.danlhenry.com/.../keil_code.png
#include <lpc23xx.h> #include <stdint.h> char ch; int main() { PINSEL0 |= 0x40000000; /* Enable TxD1 pin */ PINSEL1 |= 0x00000001; /* Enable RxD1 pin */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLM = 0x00; U1DLL = 78; /* 9600 Baud Rate @ 12MHz Clock */ U1LCR = 0x03; /* DLAB = 0 */ U1FCR = 0x07; /*Enable FIFO */ while(1) { if (U1LSR & 0x01) /* Check if data is ready in RBR */ { ch=U1RBR; /*Read receiver buffer*/ } } }
Where are you detecting an overrun error? That code just sits in an infinite loop waiting for a character to arrive, and when it does it gets removed.
What do you want to do with the character received? it's just discarded.
You're not stopping the code in the debugger and then manually checking registers, are you?
You need to check the chip documentation, but the UART probably continues to receive characters - then, if the debugger's stopped the code, you obviously will get an overrun error!