Power management of UART Peripheral using APP_UART module

koniho gravatar image

asked 2017-08-21 21:42:46 +0200

updated 2017-08-21 21:51:58 +0200

For applications using the application UART Module) via APP_UART_FIFO_INIT() without hardware flow control - how does an application put the UART peripheral to sleep?

There is the app_uart_close() but there does not appear to be a corresponding 'open()' call. The only way to 'open' the UART is to call APP_UART_FIFO_INIT() again but there is a note in the description indicating:

Note: Since this macro allocates a buffer and registers the module as a GPIOTE user when flow control is enabled, it must only be called once.

Looking at the definition of APP_UART_FIFO_INIT() - it looks like this should be OK since the buffers will be expanded to function scoped static variables - but this doesn't seem right. Is there another method to handle power management of a UART instance created via APP_UART_FIFO_INIT() ?

edit retag flag offensive close delete report spam


Any update on this question? Maybe a simple update of the documentation would suffice.

koniho ( 2017-09-10 20:21:28 +0200 )editconvert to answer

1 answer

Sort by » oldest newest most voted
jornfr gravatar image

answered 2017-09-13 11:59:07 +0200

Hello koniho

I have looked into this and it turns out that if you repeatedly call the init macro and the close function, duplicates of the buffers will be created and you will eventually run out of memory. If you need to initialize and uninitialize the UART repeatedly I suggest you define the buffers in main instead, and call app_uart_init directly. This will allow you to pass the same buffers to the init function rather than creating duplicates.

Best regards

Jørn Frøysa

edit flag offensive delete publish link more


Thanks for the update. Would it be safe to call repeatedly if Flow Control is disabled then?

koniho ( 2017-09-14 03:00:56 +0200 )editconvert to answer

Unfortunately, no. I've noticed the wording is a bit off in the function description. Only the GPIOTE part applies to hardware flow control, the buffers are needed for rx and tx in both cases. So it will register the module as a GPIOTE user only if hardware flow control is enabled, but it will allocate the buffers regardless of HWFC settings.

Jørn ( 2017-09-14 13:34:57 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower


Asked: 2017-08-21 21:42:46 +0200

Seen: 53 times

Last updated: Sep 13