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

nRF9160 RX interrupt not triggering after UART disabled and enabled again

Hi,

I am using ncs 1.0.0 in nRF9160. 

I have enabled UART 2 interrupt during initialization of the uart as below and it works fine. 

Fullscreen
1
2
3
4
uart = device_get_binding("UART_2");
uart_irq_callback_set(uart, uart_cb);
uart_irq_rx_enable(uart);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

To reduce the power consumption i need to disable the UART2 when it is not needed. 

I have disabled the UART2 as below 

Fullscreen
1
nrf_uarte_disable(NRF_UARTE2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But when i enable the UART2 I am not getting UART 2 RX interrupt. 

I have enabled the UART 2 as below 

Fullscreen
1
nrf_uarte_enable(NRF_UARTE2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Can you help me in finding why UART RX interrupt doesn't work after i disable and enable the UART 2. 

Regards,

Smitesh Mali

  • Hi Smitesh,

    The implementation of this functionality in uart_nrfx_uarte.c is not correct.
    You have to stop via TASKS_STOPRX and then wait until you get EVENTS_RXTO, and then you can disable.

    Please look at this documentation for more details.

    (here is a snippet on how to disable UART RX)

  • Hi,

    I disabled the UART as below 

    Fullscreen
    1
    2
    3
    NRF_UARTE2_NS->TASKS_STOPRX = 1;
    NRF_UARTE2_NS->TASKS_STOPTX = 1;
    while(NRF_UARTE2_NS->EVENTS_RXTO==0);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I enabled it like below 

    Fullscreen
    1
    2
    NRF_UARTE2_NS->TASKS_STARTRX = 1;
    NRF_UARTE2_NS->TASKS_STARTTX = 1;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    But i observed that current consumption on "power profiler" is around 500 uA. 

    When i was turning off the UART 2 using "nrf_uarte_disable(NRF_UARTE2)" i was getting 7 uA current.

    am i doing turning off UART 2 correctly ?

    Regards,

    Smitesh Mali

  • Hi Smitesh,
    Please try to stop via TASKS_STOPRX and then wait until you get EVENTS_RXTO, and then you can disable UART via the function you did in the first post.

    And when you are going to enable UART again you send:

    NRF_UARTE2_NS->TASKS_STARTRX = 1;
    NRF_UARTE2_NS->TASKS_STARTTX = 1;
    and then 

    nrf_uarte_enable(NRF_UARTE2);

  • Hi,

    The method suggested by you creates other random issues.

    Like MQTT connection failure and Hard fault. 

    Regards,

    Smitesh Mali

  • Hi Smitesh,
    I am very sorry for the delay, but I would assume that you have progressed from this issue (?)

    If not please share a code snippet on how you implemented this and some serial log output would be nice.

    I would also recommend enabling Debug logs in your application.