Hserial1_ChangeBaud xxx addition leads to corrupt HRSOut1 data

Started by ArifCan, Jun 01, 2025, 01:52 PM

Previous topic - Next topic

ArifCan

Dear All,
I have set budrate as follows: Declare Hserial1_Baud = 38400. In the running program I want to change the rate.
As soon as I add following line to my code, in order to change the baud rate, my code starts working incorrect:
HSerial1_ChangeBaud 19200. So, I cannot change the baud rate.
I also tried "HSerial1_ChangeBaud(19200)", "HSerial_ChangeBaud 19200" and HSerial_ChangeBaud(19200).
Instead of sending the words "Hello CAN" very quickly in a few miliseconds, it takes the code about 2,5 seconds to finish sending and I receive only "null" characters on Realterm.
I use 18F26K22.
Positron compiler: 4.0.4 build 7.
Positron Studio2:  2.1.0 build 4.
Oparating system: Win 11.
Any Idea?

John Lawton

I believe that Hserial1_Baud sets the baud rate during compilation only, so can't be used to change speed during execution, you'll need to change the register settings.

John

Yasin

Hello, I can change it at runtime with the "Hserial_ChangeBaud" command. There is no problem. Your problem occurs because the PLL is active. Your code in the write "Declare Xtal = 8", there will probably be no problem.

ArifCan

Thanks John. Before reaching to registers I would like to try to make the "Hserial_ChangeBaud" work, since it is shown as a command in the user manual Page 228.
Thanks Yasin. I changed the line "Declare Xtal=32" to "Declare Xtal=8" but it did not help. I have the same problem.