UART not powering down Zephyr

Hi,

I am using nRF Connect SDK V2.3.0. How can I power down the UART?

I am using the Interrupt-driven UART API, interrupt driven on RX and polling on TX. I have disabled the console on the dtb and prj.conf. I am using both UARTs in my application to talk to external peripherals (so I do not need logging nor the console on any of the UARTs). My application is a very low power application, micro amps matter here.

When I do not use the UART my power consumption is nice and low. As soon as I use the UART my power consumption jumps by 1.3mA, not good to say the least. I have tried to use the power manager "pm_device_action_run(uart, PM_DEVICE_ACTION_SUSPEND)", but my power consumption does not drop. I know it is the UART and not something else on my board, because as soon I issue the forbidden register writes, the power consumption drops down to micro amps again:

*(volatile uint32_t *)0x40002FFC = 0;   // Power down UARTE0
I did look at the NRFX UARTE drivers also and they are no good, I cannot know the size of the expected packet, nor drop packets due to a timeout.
.

My question is how can I power down the UART when I am not using it (simular to uninitializing it in the old nRF52 SDK) and then powering it up again when I need it? So technically I want a way to uninitialse the UARTs and re-initialise them again when I need them to save as much power as possible.

Thank you in advance for the assistance. Hope to hear from someone soon.

Kind Regards

Julian

  • Hi Edvin,

    Thank you so much for testing my application. That is excellent news.

    I have a theory of what is going on here. Like mentoined before I have a RS232 converter attached to UART0 that I power up. I think what is happening is because I cannot control when the UART gets initialised the RS232 converter gets powered up after the UART is initialised. This causes a framing error (or other error) on the UART and then the UART does not want to power down. By reading from the UART I suspect in the driver somewhere (in Zephyr) it clears the error flags.

    So my question is how can I clear the error flags directly with Zephyr (without reading or waiting to receive data from the UART)?

    I will test if it works if you can just tell me how to clear the errors. Thanks in advance. I believe we are close to solving this.

    Kind Regards

    Julian

  • JulianWilmot said:
    This causes a framing error (or other error) on the UART and then the UART does not want to power down.

    What does this look like  in your application? Do you see it in the logs or something?

    I see that pm_device_action_run() runs a few checks, and returns an error if it is not able to run properly. Do you see the return value of pmm_device_action_run not being 0? Can you try to step through this function to see how it behaves in your case?

    BR,

    Edvin

Related