This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Acquiring GPS data through UART on a polling basis.

I'm able to successfully use peripheral/uart example to read the data from GPS module. I achieved the same by setting baud rate to 4800, and connecting rx and tx of GPS to pins 6 and 8 respectively. Currently I have the GPS data printed on my console(CoolTerm). 

While the GPS module is continuously throwing data out of UART, how can I read this GPS data from UART only at specific intervals?

Is there a way where I can perform something like this? Enable UART, Collect data, Disable Uart. Again when I need GPS data, repeat the same procedure.

I also tried to incorporate a delay in my code to check if I can finish all my other tasks and then come back to read the data. But my console shows nothing!

while (true) {
    uint8_t cr[250];
    while (app_uart_get(&cr[gps_idx]) != NRF_SUCCESS);
    while (cr[gps_idx] != '\r') {
        gps_idx++ ;
        while (app_uart_get(&cr[gps_idx]) != NRF_SUCCESS);
    }

    printf("GPS Data One line end\r");
    for (int j=0; j<=gps_idx; j++) {
        printf("%c", cr[j]);
    }
    printf("GPS Data One Line printed\r\r");
      
    gps_idx = 0;
    
    // Works fine without this delay
    nrf_delay_ms(1000);
}

Parents
  • The nrf_delay_ms(1000); stalls the CPU for 1 sec. at that point in your while loop. 

     

    I would invite you to look at the GPS whitepaper and configure it to send a signal through the "Directive" line when the GPS data is ready, and connect that line to one the GPIOs to the nRF device. Then use that interupt to start reading the UART data from the GPS module.

    I see that you can configure the GPS module to send data in intervals. 

     

Reply
  • The nrf_delay_ms(1000); stalls the CPU for 1 sec. at that point in your while loop. 

     

    I would invite you to look at the GPS whitepaper and configure it to send a signal through the "Directive" line when the GPS data is ready, and connect that line to one the GPIOs to the nRF device. Then use that interupt to start reading the UART data from the GPS module.

    I see that you can configure the GPS module to send data in intervals. 

     

Children
Related