promblem about GPS rx buffer libuartes

Hi,
I'm developing an application using Libuartes to handle GPS data
1. According my knowledge about Libuartes, It will call the NRF_LIBUARTE_ASYNC_EVT_RX_DATA when the buffer is full (or the incoming data has "\r","\n" to indicate TX buffer was completed (please confirm this point for me.)

2.  But in fact, when I test with my terminal (Hercules), I send every string to my nrf then the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event was call and RX buffer receive exactly what I sent (even the size of buffer I have sent is not equal with RX buffer and no  "\r""\n").
When I test with my GPS module. the NRF_LIBUARTE_ASYNC_EVT_RX_DATA was called when my RX buffer is full (but when I connect with my GPS with Hercules) GPS data has "\r"\n" at the last every data.
Ex:
a.  When I connect GPS directly with Hercules : every 1s I receive data one by one
"12345"
after 1s
"12345"
after 1s 
"12345"
b. When I connect GPS directly with NRF with Libuartes RX buffer configuration : 15
I wait 3s to received the whole data like above at 1 time. I need every 1s my debug will show "12345" not after 3s I receive 
"12345"
"12345" 
"12345" 

So what is the difference in here ?. The way of NRF handle RX data from incoming data (I send text by Hercules) and (GPS) not is the same 
 

  • Hi I think I found the reason 

    1. I use 2 libuarte with configurations
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 2, 3, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    libuarte2 used to communicate with GPS and it get this problem

    but I convert the libuarte configuration into ibuarte2, libuarte2 can receive data realtime

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 2, 3, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    But I got the same  problem in libuarte. (It only call event NRF_LIBUARTE_ASYNC_EVT_RX_DATA when the buffer RX full). I apply these configuration for libuarte example and I got the same problem.


     nrf_libuarte_async_config_t nrf_libuarte_async_config = {
                .tx_pin     = TX_PIN_NUMBER1,
                .rx_pin     = RX_PIN_NUMBER1,
                .baudrate   = NRF_UARTE_BAUDRATE_115200,
                .parity     = NRF_UARTE_PARITY_EXCLUDED,
                .hwfc       = NRF_UARTE_HWFC_DISABLED,
                .timeout_us = 100,
                .int_prio   = APP_IRQ_PRIORITY_LOW_MID 


    I don't know why when I change RTC and Timer 1,2 into 2,3 => I need to set  .int_prio = APP_IRQ_PRIORITY_LOW_MID. 




  • Hi 

    If you set _timer1_idx to NRF_LIBUARTE_PERIPHERAL_NOT_USED (the 5th parameter) then the timeout functionality will not be used, and the _rtc1_idx parameter will be ignored. 

    In other words you need to provide a second timer to the interface in order to use timeout. 

    Could you try this and see if it works better for the GPS sensor?

    Best regards
    Torbjørn

  • During the time that I wait for response I set the 

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte2, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3); 

    And it work. But I dont understand clearly about that !

    1. I find that when I set (the 5th parameters) is "1" or "3" I will got this problem ? so Why ?

    2. And why I need to use NRF_LIBUARTE_PERIPHERAL_NOT_USED (app_timer) ? How it different from my mistake ?

    If you set _timer1_idx to NRF_LIBUARTE_PERIPHERAL_NOT_USED (the 5th parameter) then the timeout functionality will not be used, and the _rtc1_idx parameter will be ignored. 

    Can you explain for me more clearly ?
    I'm have many confusion about rtc and timer and NRF_LIBUARTE_PERIPHERAL_NOT_USED in libuartes.

    Please give me as much information as possible, because waiting for reply is very long.

    Thank you very much ! 

  • Hi

    It's important to be aware that when you are using the SoftDevice and app_timer modules only RTC2 is available for the application, or for the LIBUARTE module. The reason for this is that there are only three RTC modules in the nRF52 devices, and RTC0 is used by the SoftDevice while RTC1 is used by the app_timer. 

    In terms of timers you have 5 in total, and only TIMER0 is used by the SoftDevice, so you should be able to use timers 1, 2, 3 and 4 for LIBUARTE. 

    Your configuration works because you only use RTC2, TIMER1 and TIMER2, which means there is no conflict between peripherals. 

    Pham Tam said:
    1. I find that when I set (the 5th parameters) is "1" or "3" I will got this problem ? so Why ?

    It is hard to say why this problem occurs. If you have set the timeout to 100us, then the libuarte driver should trigger the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event approximately 100us after the last byte was received from the GPS module, and you should not need to wait for the buffer to fill up. 

    Would you be able to share the source code for the code that configures and uses the libuarte driver when you get this issue so I can have a look at it? 

    If you don't want to share your code in a public case just let me know, and I can make the case private. 

    Best regards
    Torbjørn

Related