RS232 with different baud rates

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

RS232 with different baud rates

Post by Jan Lichtenbelt »

I want to use RS232 with starting at 38400 baud rate. But later on in the program I want to change the baud rate to 19200. How can I realise that?

Kind regards

Jan Lichtenbelt

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: RS232 with different baud rates

Post by Dan81 »

Hello Jan

That is for a Hardware solution.

When you want to change the baud rate :
Put a 'C code" icon with :
spbrg = ?? ;

If you want to know the value of ?? :
With the right value of the Quartz frequency. (19.66MHz for a Matrix board)

In the RS232 properties : choose 19200
then
- Chip / Compile to C
- Chip /View C
- search : " SPBRG_VAL "
- the answer will be something like :
. #define RS232_8520508_SPBRG_VAL 69 (here for 19.66MHz)
- replace ?? by your value (here 69)

Then put again 38400 in the RS232 properties.

Be sure that all datas have been sent before changing "spbrg"


Daniel

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: RS232 with different baud rates

Post by Jan Lichtenbelt »

Dear Daniel

Thanks a lot. This made me to start to look more in detail RS232.

I found the follwoing:
1) The Baud Rate Generator SPBRG can be calculated from the figure below (from datasheet of 12F1840)
SPBRG.jpg
SPBRG.jpg (38.17 KiB) Viewed 2777 times
2) The High Baud Rate Select bit (bit2 of TXSTA register) must be set for baud rates >= 4800. In that case set in C-code: txsta= 0x04; else txsta=0;

3) In my case I found an other difference in the bitbanched baud rates. The bitbanched BAUT Rate Delay is for baud rate >=2400 equal to 998400/baudrate. (for baudrate 1200 this delay is 833). How to change this value in C-code is not clear to me. Perhaps changing the value RS232_66470_SW_BAUD, but I do not know what the meaning is of 66470 values and if this one does not change in other applications (microcontrollers).

Kind regards,

Jan

Post Reply