cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 with GPS

jameslenvo
Associate II
Posted on April 07, 2015 at 00:21

Hi there,

I'm trying to parse some GPS data, to do this I want to limit the NMEA string coming from my GPS. I've found online that I can send the following to the Rx pin of my GPS to tell it to just send the GPGGA line, but it doesn't seem to work. Here is the line: ''PMTK314,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0*2C<CR><LF>\r\n'' I'm sending it with my USART3 Tx function (send string function). If I add it in my interrupt, it malfunctions the output of the GPS to create data that is not worthy of anything. Notice I have two different sendstring functions, USART_SendString is for UART2 (Sending data only) and UART_SendString3 is for UART3 (Sending Data, UART3 also receives data) Here is my related code.

//void USART3_IRQHandler(void) {
//USART_SendString3(''PMTK314,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0*2C<
CR
><
LF
>\r\n'');
/*
if (( USART_CR1_RXNEIE) && (USART_CR1_TXEIE) != RESET){
USART_SendString3(''PMTK314,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0*2C<
CR
><
LF
>\r\n'');
rx = UART_read();
USART_SendString(&rx);
}
int main (void) {
Clock_init ();
GPIO_init ();
UART_init ();
// LCD_init ();
while (1) {
}
}

6 REPLIES 6
Posted on April 07, 2015 at 00:38

You understand that <CR><LF> are a description of the 13 and 10 characters, and not typed literally, right?

That '' '' is C notation for the same.

#include <
stdio.h
>
int main(int argc, char **argv)
{
printf(''%d
'','
');
printf(''%d
'','
');
return(1);
}

There is a leading '$' on the PMTK314 command. Don't send multiple bytes to the USART in the interrupt.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on April 07, 2015 at 00:51

Your checksum is also wrong.

This is the string you want to be sending

''$PMTK314,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0*2B\r\n''

I think you need to review some basic documentation here.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jameslenvo
Associate II
Posted on April 07, 2015 at 03:42

Wow thank you!! I totally misunderstood all that, but after your comments I did some googling and it works as I hoped. 

jameslenvo
Associate II
Posted on April 08, 2015 at 01:05

Ok, sorry for the double post. I just fixed my LCD error. However, now I'm getting doubts my interrupt truly work. I tried to do some heavy lifting of parsing my code in my main loop and simply setting a flag in the interrupt to tell main to do the work, but it seems as though this never gets set? I understand I can't place delays in my ISR, so I thought setting a flag would be the best method.

Below is my code :

#include ''uart.h''
#include <
stdlib.h
>
#include <
stdio.h
>
#include <
string.h
>
volatile int flaggo = 0;
int main (void) {
char rx;
Clock_init ();
GPIO_init ();
UART_init ();
LCD_init ();
USART_SendString3(''$PMTK314,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0*29

'');
while (1) {
if (flaggo){
rx = UART_read();
USART_SendString(&rx);
flaggo = 0;
}
}
}
void USART3_IRQHandler(void) {
char rx;
//while (( USART_CR1_RXNEIE) && (USART_CR1_TXEIE) != RESET){
while ( (USART_CR1_RXNEIE) != RESET) {
rx = UART_read();
if ((rx == '
') || (rx == '
')) {
flaggo = 1;
//NVIC->ISER[0] |= NVIC_ICER_CLRENA_0;
}
}
}

Posted on April 08, 2015 at 03:05

I've written several threads on NMEA processing. Your interrupt would work a bit better if you accumulated a line of data.

Please check

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Issue%20with%20USART%20RX%20buffer%20and%20char%20filter&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5...

.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jameslenvo
Associate II
Posted on April 08, 2015 at 03:28

Hi Clive, thanks for the link. I've tried to implement that exact interrupt, but I still use RXNEIE and nothing gets to my main loop or any other function, do you happen to know how to disable the RXNEIE flag?