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

Change UART baudrate at runtime with uart_configure (Zephyr)

Hello,

I'm in nRF Connect SDK 1.5 and I have to change the baudrate of UART1 at runtime. I have to use Zephyr UART Functions. I have tried the function uart_configure().

I'm able to send and receive interrupt based with the baudrate in the devicetree.

I have tried following:

First i send with the devicetree baudrate. Then the following code is executed, after the second uart_config_get the baudrate is 115200. But i still send on the devicetree baudrate.

    uart_config_get(uart_device, &cfg);
    cfg.baudrate = 115200;
    
    config_err = uart_configure(uart_device, &cfg);
    if(config_err)
        LOG_ERR("UART configure error %d", config_err);
        
    uart_config_get(uart_device, &cfg);

config

CONFIG_UART_1_INTERRUPT_DRIVEN=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_1_ASYNC=n
CONFIG_UART_ASYNC_API=n

Is there anything else I have missed to call or configure?

Thank you

Parents Reply Children
No Data
Related