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

libUARTE timer working expl. with app timer

Hello,

I was reading the nrf_libuarte_async library, and noticed that in the

app_timer_handler - 

calls the

local_app_timer_start -

 again and starts the timer again,

could shed some light on why this is called again and also on how the timeout timer works (with app timer).

the timer is started in the enable function, shouldn't it be started after the first byte is received ? could please elaborate on this?

Also follow up question  - the app time starts in the enable function and not after the first byte recived, how does this work ? ideally we should start timer after we detect idle line right ?

please clear this up

i know that timer0 is for counting bytes recived,

timer1 and app_timer and rtc are options for timeout timer.

Parents
  • Hello,

    Exactly why it is done like this, I don't know, but I assume that it is related to the fact that things go quite quick when using UART, and it may be that starting and stopping the timer on every byte would be too much for the app_timer, so instead, they only check whether any bytes has been received since the last timeout, and if not, it will generate the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event.

    Why they use this single shot timer that is started on each timeout instead of a repeated timer, I don't know. 

     

    Also follow up question  - the app time starts in the enable function and not after the first byte recived, how does this work ? ideally we should start timer after we detect idle line right ?

     I guess it is for the same reason. Since this goes very fast, I imagine that there wouldn't be any time for the app_timer scheculer to actually start the timer. You see, app_timer_start() doesn't actually start the timer, but it schedules the timer to be started, so if the UART bytes are coming in too fast, the timer scheduler will not have enough time to actually start the timer, which depending on the baudrate may not be until the entire message is sent.

    Best regards,

    Edvin

Reply
  • Hello,

    Exactly why it is done like this, I don't know, but I assume that it is related to the fact that things go quite quick when using UART, and it may be that starting and stopping the timer on every byte would be too much for the app_timer, so instead, they only check whether any bytes has been received since the last timeout, and if not, it will generate the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event.

    Why they use this single shot timer that is started on each timeout instead of a repeated timer, I don't know. 

     

    Also follow up question  - the app time starts in the enable function and not after the first byte recived, how does this work ? ideally we should start timer after we detect idle line right ?

     I guess it is for the same reason. Since this goes very fast, I imagine that there wouldn't be any time for the app_timer scheculer to actually start the timer. You see, app_timer_start() doesn't actually start the timer, but it schedules the timer to be started, so if the UART bytes are coming in too fast, the timer scheduler will not have enough time to actually start the timer, which depending on the baudrate may not be until the entire message is sent.

    Best regards,

    Edvin

Children
No Data
Related