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
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
Hi Jorgen,
1.Sorry for telling i am little bit confused about api uart_configure and all
2. My Suggestion is could you provide a example with example code if possible
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,
Thank you for this code
1. When i paste this code in echo bot as you say at starting point
2. I got so many errors please check from your side and rectify the errors
Tharak said:1. When i paste this code in echo bot as you say at starting point
I did not say that I pasted the code at the starting point of the sample, I said I used the sample as a starting point for adding this code.
Tharak said:2. I got so many errors please check from your side and rectify the errors
I did run the code at my end, and it is working properly (I used nRF Connect SDK v2.0.0). Put the code after this line.
If you get any errors, you need to post the errors here if you want me to help you resolve them.
Hi Jorgen,
1. I tried the code after print_uart statement
2. I didnt got anny errors thats fine
3. But my ulitimate goal is i need to print the statement in 19200 baud rate
4. When i use your code and changed baud rate from 1000000 to 19200 its wont work
5. i think my problem you understood and i checked in build/zephyr/zephyr.dts file its showing 115200 baud rate