Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Disabling UART RX issues

I am experience some for me strange behavior with UART0 on a nrf52832. Let me explain:

First I initialize the UART using:

APP_UART_FIFO_INIT(...)

with parameters setup to match my requirements. I assume this done on UART0 since there is no parameter specifying the UART instance. After initialization the UART is enabled, but I don't want the RX to be enabled from start so I disabled it using this:

static nrf_drv_uart_t m_uart = NRF_DRV_UART_INSTANCE(0);

nrf_drv_uart_rx_disable(&m_uart); (which I can see actually sends the TASKS_STOPRX command to the UART).

Right after calling nrf_drv_uart_rx_disable(&m_uart), I receive an UART interrupt in my APP_UART_CALLBACK_HANDLER with type APP_UART_DATA_READY and data = 0. Why is that so (I see the EVENTS_RXTO is asserted but that shouldn't generate a APP_UART_DATA_READY interrupt).

Also after having disabled the RX I wouldn't expect the RX to be able to receive data on UART RX. However it just keeps handling incoming data on the UART RX generating APP_UART_DATA_READY  interrupts. This is not what I expected after disabling the UART RX. However calling app_uart_close(); instead, I don't get the APP_UART_DATA_READY interrupt and the UART RX is actually disabled as expected. What's the difference?

What's the the proper way of bringing the UART into sleep (low power mode). Is it enough to issue TASKS_STOPRX and TASKS_STOPTX commands?

I am using SDK14.0.

BR

Kim

Parents
  • Hi Kim

    The nRF52832 only has one UART interface, so you have to use UART0 or UARTE0. 

    Which instance to use is set by the index provided in the NRF_DRV_UART_INSTANCE(index) macro. 

    In general you should not use any of the nrf_drv_uart functions if you are using a higher level UART library such as app_uart. 

    To really ensure minimal sleep current it is best to disable the UART completely, using app_uart_close(). 

    Also, if you were using a later SDK I would recommend switching to the nrf_libuarte driver, but in SDK v14.0.0 this one is not available. 

    Best regards
    Torbjørn

  • Yes I see using using both the higher level app_uart library and the lower level driver functions in the same application, things gets "messed up" in the app library. Using the the app_uart library only seems to solve the issues. Thanks for your advice.

    Br

    Kim 

Reply Children
Related