Skip to main content
SARTHAK KELAPURE
Associate III
November 23, 2017
Solved

storing GPS data in a buffer via USART1 on STM32L072CZ

  • November 23, 2017
  • 3 replies
  • 987 views
Posted on November 23, 2017 at 12:01

Hello everyone, I am using STM32L072CZ board to get data from GPS on USART1 but when I try to store it onto a buffer, I am losing data bytes. I am putting a small code snippet here, not the final version but somewhere what I am trying to do

for(int i=0;i<500;i++)

{

buffer[i]=USART1->RDR;

}

for(int i=0;i<500;i++)

{

LPUART1->TDR=buffer[i];

}

I am losing most of my data during this process. Please help.

#stm32l0-stm32l0-discovery #gps #usart1-commun #serial-port #communication
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on November 23, 2017 at 13:31

You can't just jam data into the registers. You need to wait on TXE or RXNE bits to assert in SR or ISR register. 

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 23, 2017
Posted on November 23, 2017 at 13:31

You can't just jam data into the registers. You need to wait on TXE or RXNE bits to assert in SR or ISR register. 

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AvaTar
Senior III
November 23, 2017
Posted on November 23, 2017 at 13:53

And GPS (I assume NMEA0183) has strings of variable length, with defined start and end characters.

Not gonna be that simple.

Andrew Neil
Super User
November 23, 2017
Posted on November 23, 2017 at 17:16

for(int i=0; i<500; i++)
{
 buffer[i] = USART1->RDR;
}�?�?�?�?

Think:

  1. how long will it take to execute 1 iteration of that loop?
  2. how long does 1 character take to complete at whatever baud rate you're using?
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.