Page 1 of 1

UART baud rate change in the program

Posted: Sat Jan 11, 2025 5:02 pm
by ChrisT66
Hi,
is there anything to consider when using the command CahngeHWBaud to change the UART in the program from 9600 to 115200? Unfortunately this does not work properly for me.

Thanks for your help

Re: UART baud rate change in the program

Posted: Sat Jan 11, 2025 5:23 pm
by LeighM
Could you give us a sample program?
This would at least tell us the target device.
When you say it doesn't work, what does it do?
Stay at 9600?

Re: UART baud rate change in the program

Posted: Sat Jan 11, 2025 7:10 pm
by ChrisT66
Yes, I know that was a bit short on information. I just wanted to ask if there are any known issues.
The controller is an ATMEGA328P. Something strange is happening, I think there is a bug. I can't tell what baud rate it's running at after the command, all I know is that it stops receiving. If I start at 9600 and then switch to 115200 it doesn't work, if the UART is running at 115200 it works. I also have the same problem when I monitor the UART input via an interrupt. I activate the interrupt with different macros using an IF query. If, for example, the result of the query is "Yes" and the "No" branch also contains an activation of the RX interrupt, then no reception works, even if I deactivate the "No" interrupt activation! only when I delete it does it continue to run without errors.
The program is big and has many irrelevant parts, I have to make a small demo version to post it here: ....

Re: UART baud rate change in the program

Posted: Sat Jan 11, 2025 7:35 pm
by mnfisher
There is some code at https://www.flowcode.co.uk/mmforums/vie ... te#p103383 which did this for the Arduino Mega and 328p.

Martin

Re: UART baud rate change in the program

Posted: Sun Jan 12, 2025 7:06 am
by ChrisT66
Hi Martin,

Thank you! I nearly went mad with the error.
That works, great :)