This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nrfx_uarte works in non-blocking mode but nrfx_uart can only send 1 byte.

Hi,

I am working on a 2-wire uart to save GPIO and try to get as low current consumption as I can get.

Here is how I want it to be:

My custom 52840 board have 2-wire rx/tx connected to a sensor's UART and there is no RTS/CTS.

After received UART data from the sensor, 52840 will wake up and then process the data sent by the sensor and then back to sleep again.

The sensor will resend uart data until hear UART response from 52840, so I don't need to worry about data lost.

I looked up in devzone and found out that I can not use zephyr uart driver or lpuart to achieve my goal.

(Or is there a valid approach that I do not find?)

I checked sample/nrf/nrfx_prs, I think I can follow this sample and make it works like this:

Config rx pin of 52840 as an GPIO and register an IRQ.

When there were data comes in then reconfig UART at runtime using nrfx_uarte_init() and start sending/recving data.

After no more data comes in, call nrfx_uarte_uninit and reconfig the rx pin to GPIO and register an IRQ to save power.

It works using nrfx_uarte_init() and then use nrfx_uarte_tx() to send data using non-blocking mode.

Then I found this thread: 52833-uart-power-consumption, It looks like using EasyDMA will have a higher current consumption.

So I try to use nrfx_uart to replace nrfx_uarte. This is where I met the issue:

After I changed .overlay to use "nordic,nrf-uart" to replace "nordic.nrf-uarte", and use nrfx_uart_xxx APIs to replace nrfx_uarte_xxx APIs.

Then I put 12 bytes in the tx buffer of nrfx_uart_tx() and only 1 byte recved. (I use a USB-Serial cable to connect 52840 with my PC and with nrfx_uarte_xxx APIs, it works properly)

Then I try to set the callback func to NULL in nrfx_uart_init() to make it works in blocking mode, after that all 12 bytes recved.

Removed all my code and only called nrfx_uart_init() and nrfx_uart_tx() and the issue is still there.

Any suggestions?

How can I use nrfx_uart in non-blocking mode?

Regards,

Anthony Yuan

  • Thanks Jared and I am using nrfx_uarte APIs to write my own uart driver.

    Here is what I see on my 840 DK:

    1, DK start up and before nrfx_uarte_init(), average current is 20uA.

    2, After nrfx_uarte_init(), I can read/write uarte properly and average current when there is no data transfer is around 305uA.

    3, Wait 5 seconds without uart data comes in/out, call nrfx_uarte_uninit(). But there is still 135uA current consumption:

    I checked uart_nrf_sw_lpuart() and I think I need to turn off HFXO(high frequency RC oscillator) after uninit uarte, to resume 20uA average power consumption.

    a) Should I using onoff manager to turn off HFXO? As my driver is using nrfx_uarte APIs directly, is there any suggested HAL/driver layer API to turn off HFXO?

    b) Any other suggestions on turn off uart to get the lowest current consumption?

    Regards,

    Anthony Yuan

  • Hi,

    Do you turn on the HFXO clock explicitly? If not then the UARTE driver will use HFINT, and disable it automatically when you uninit the driver. In that case the current consumption would be something else. 

    Could you post the PPK trace?

    regards

    Jared 

Related