Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] UART Serial Communication: Bytes Lost

Status
Not open for further replies.

kulks

Newbie level 6
Newbie level 6
Joined
Apr 25, 2013
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,427
Hi,

I have interfaced a Garmin GPS to my ARM based microcontroller (LPC 1768) using serial communication. These are the steps am following to read the data

1. Read first 2000 characters from Receiver buffer register and store it in an array.
2. Whenever the count reaches 2000, disable the interrupt and set a flag to 1.
3. When flag is set to 1, parse the characters from the stored array and search for pattern match and when pattern matches extract latitude and longitude.
4. Enable the interrupt again and set the flag to 0 to read the next set of characters.

But with this approach I'm losing the bytes. Pattern doesn't match.

UART initialization includes.

1. Baud rate set to 4800 bps..same as the GPS.
2. Enable Receiver FIFO to receive single character at a time.

I have set the buffer size to a very high value i.e 2000 with an intention that at some point of time, I might receive the data format which i require.

Please help me figure out where am I possibly going wrong?
 

Hi,

I have interfaced a Garmin GPS to my ARM based microcontroller (LPC 1768) using serial communication. These are the steps am following to read the data

1. Read first 2000 characters from Receiver buffer register and store it in an array.
2. Whenever the count reaches 2000, disable the interrupt and set a flag to 1.
3. When flag is set to 1, parse the characters from the stored array and search for pattern match and when pattern matches extract latitude and longitude.
4. Enable the interrupt again and set the flag to 0 to read the next set of characters.

But with this approach I'm losing the bytes. Pattern doesn't match.

UART initialization includes.

1. Baud rate set to 4800 bps..same as the GPS.
2. Enable Receiver FIFO to receive single character at a time.

I have set the buffer size to a very high value i.e 2000 with an intention that at some point of time, I might receive the data format which i require.

Please help me figure out where am I possibly going wrong?


The above logic is wrong. I had to implement a ring buffer to store the received bytes in the ISR and read the bytes in the main loop. Care has to be taken to disable the interrupt while you are reading as it might lead to overwriting of data.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top