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

Power management of UART Peripheral using APP_UART module

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() ?

Parents
  • 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

  • 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.

Reply Children
No Data
Related