2015-04-06 3:21 PM
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) {
}
}
2015-04-06 3:38 PM
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.
2015-04-06 3:51 PM
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.2015-04-06 6:42 PM
Wow thank you!! I totally misunderstood all that, but after your comments I did some googling and it works as I hoped.
2015-04-07 4:05 PM
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;
}
}
}
2015-04-07 6:05 PM
I've written several threads on NMEA processing. Your interrupt would work a bit better if you accumulated a line of data.
Please check .2015-04-07 6:28 PM
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?
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.