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

How to enable and check for RX timeout using libuarte?

I want to check for an RX timeout after sending a TX.

I am puzzled on how this comes about.

As best I can tell I have enabled TIMER3 for the timeout.

NRF_LIBUARTE_ASYNC_DEFINE(uart1, 1, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 3, 255, 3);

I have created a timeout of 50*1000 us. (50ms)

    nrf_libuarte_async_config_t uart1_config = {
            .tx_pin     = UART1_TX_PIN,
            .rx_pin     = UART1_RX_PIN,
            .baudrate   = NRF_UARTE_BAUDRATE_19200,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 1000*50,
            .int_prio   = APP_IRQ_PRIORITY_LOW
    };

I have read that maybe the timeout comes back during the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event but I'm unsure and I'm also unsure what triggers the timeout begin.

void uart1_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
	nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
	ret_code_t ret;

	switch (p_evt->type)
	{
	
	...
	
	case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
	
	if (p_evt->data.rxtx.length == 0)
      {
        printf("Receive Timeout Occured\n");
      }
      else
      {
        //We received data, do something with it. 
        printf("%s",  p_evt->data.rxtx.p_data);
      }
                  
  ...

Kind regards.

Parents
  • Hi Christopher,

    I understand that it is not as simple to decrypt the advanced features of this timer just from the documentation

    I think the whole feature relies on which timers you used in your libuarte_async module definition. The timer0_idx is used for byte counting and the timer1_idx is used for timeouts (if timer1 is not used then rtc1_idx will be used if that is also set to 0 then app_timer will be used)

    You can register the rtc_timeout handler with _name_rtc_handler where _name is same as in NRF_LIBUARTE_ASYNC_DEFINE. That rtc event handler will be called for timeouts in that case if rtc was used.

    If timer index is being used then at RX timeouts will result in an event NRF_LIBUARTE_ASYNC_EVT_RX_DATA with the amount of data received.If none is received than this event will show that the amount of data received before timeout is 0.

Reply
  • Hi Christopher,

    I understand that it is not as simple to decrypt the advanced features of this timer just from the documentation

    I think the whole feature relies on which timers you used in your libuarte_async module definition. The timer0_idx is used for byte counting and the timer1_idx is used for timeouts (if timer1 is not used then rtc1_idx will be used if that is also set to 0 then app_timer will be used)

    You can register the rtc_timeout handler with _name_rtc_handler where _name is same as in NRF_LIBUARTE_ASYNC_DEFINE. That rtc event handler will be called for timeouts in that case if rtc was used.

    If timer index is being used then at RX timeouts will result in an event NRF_LIBUARTE_ASYNC_EVT_RX_DATA with the amount of data received.If none is received than this event will show that the amount of data received before timeout is 0.

Children
No Data
Related