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
V3 Changing Baud Rates
- 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
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: V3 Changing Baud Rates
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
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
- 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
Hi Ron
Thats great glad your all up and running now.
Thats great glad your all up and running now.

Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel