cancel
Showing results for 
Search instead for 
Did you mean: 

storing GPS data in a buffer via USART1 on STM32L072CZ

SARTHAK KELAPURE
Associate II
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
1 ACCEPTED SOLUTION

Accepted Solutions
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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
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
Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead
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.

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?