V3 Changing Baud Rates

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

V3 Changing Baud Rates

Post by Ron »

Hello,

I have tried to set up the baud rate register/bits with the following in an attempt to over ride the RS232 componenet macro baud rate.

Ben had offered me this in a past post (18F4620, 20MHz, SYNC = 0, BRGH = 1, BRG16 = 1, SPBRG = 42, 115K2 Baud Rate).

clear_bit(txsta, SYNC);
set_bit(txsta, BRGH);
set_bit(baudcon, BRG16);
spbrg = 42;


When I place the above in a "C" block the program compiles fine to the 18F but never connects with my PC application. If I use the default settings using the RS232 component for 115k2 it works fine.

This tends to make me believe that I cannot over ride the component settings. Depending on the device that is connected to the RS232 port I need to be able to change the baud rate from inside my application.

Am I doing something wrong in how I am trying to override the RS232 component macro's baud rate?

Thank you,

Ron

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: V3 Changing Baud Rates

Post by Benj »

Hello Ron

Ok you could try this instead and see if this works for you.

txsta = 4; // 8-bit, async, low speed, off
spbrg = 10; // set the baud rate
rcsta = 0; // 8-bit, disabled
set_bit(rcsta, SPEN); // turn on serial interface

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times
Contact:

Re: V3 Changing Baud Rates

Post by Ron »

Hi Ben,

These worked.....

i set the component to 9600, I needed BRG16

I Added a "C" block with the following, which worked, I confirmed the baud rate using a serial port monitor.

clear_bit(txsta, SYNC);
set_bit(txsta, BRGH);
set_bit(baudcon, BRG16);
spbrg = 42;
set_bit(rcsta, SPEN); // turn on serial interface

I then tried the following, which worked, again confirmed with a serial port monitor.

txsta = 4; // 8-bit, async, low speed, off
spbrg = 42; // set the baud rate
set_bit(baudcon, BRG16);
rcsta = 0; // 8-bit, disabled
set_bit(rcsta, SPEN); // turn on serial interface

Just wanted to give you the results.

Ron

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: V3 Changing Baud Rates

Post by Benj »

Hi Ron

Thats great glad your all up and running now. :mrgreen:

Post Reply