Hi Nordic,
1.I am running (C:\ncs\v2.1.0-rc2\zephyr\samples\drivers\uart\echo_bot) but i need to change baud rate within program
2. I Can Change my baud rate using overlay file
3. But I dont want overlay file i need to make changes within program
Hi Nordic,
1.I am running (C:\ncs\v2.1.0-rc2\zephyr\samples\drivers\uart\echo_bot) but i need to change baud rate within program
2. I Can Change my baud rate using overlay file
3. But I dont want overlay file i need to make changes within program
Hi,
You can try the API uart_configure() to change the baudrate. You can get the current config using uart_config_get(), store this in a uart_config struct, change the baud rate in this struct, and set the config again.
Best regards,
Jørgen
Using the echo_bot sample as a starting point, you can do something like this:
struct uart_config uart_config_current;
if(uart_config_get(uart_dev, &uart_config_current) != 0)
{
printk("uart_config_get() returned error");
}
uart_config_current.baudrate = 1000000;
if(uart_configure(uart_dev, &uart_config_current) != 0)
{
printk("uart_configure() returned error");
}
else
{
printk("UART baudrate changed successfully");
}
If you then run a serial terminal at 1M baudrate, it should output some "garbage" (from the initial output at 115200 baudrate) and then print "UART baudrate changed successfully".
Hi Jorgen,
Please share your zip file then i can know where it is wrong
Hi,
Here is the modified sample I used for testing: echo_bot_19200.zip
I moved the changing of baud rate earlier in the application, so now all UART TX/RX will use 19200 baud rate.
Best regards,
Jørgen
Hi,
Here is the modified sample I used for testing: echo_bot_19200.zip
I moved the changing of baud rate earlier in the application, so now all UART TX/RX will use 19200 baud rate.
Best regards,
Jørgen