PDA

View Full Version : Redefinition of CON bmode during runtime



Pedro Pinto
- 16th February 2008, 12:51
Hello

I need only in the start of my program a 2400 baudrate, later im programm during runtime i need to change the baurate to 9600, but become error by the compiler "Redefinition of CON bmode"
How can i do that?

Thanks in advance

Best regards

Pedro

Charles Linquis
- 16th February 2008, 15:47
You can change your baudrate any time during runtime by issuing the command

SPBRG = x,

where "x" is a number you will find in your datasheet and
is based on your oscillator, and the BRGH and BRG16 settings.

After changing the baud rate, pause at least two byte-times before you
attempt to use the serial port.

Pedro Pinto
- 16th February 2008, 19:34
Thank You Charles

Regards

Pedro

Archangel
- 16th February 2008, 22:28
Hi Pedro,
What Charles said is proper for HSERIN and HSEROUT, I have a little program I use to test serial LCD units using SEROUT and it works for several baudrates, here is a sample of the code.


SEROUT PortB.7,N2400,[254,128,"2400 baud line 1~"]'inverted
pause 100
serout PortB.6,N9600,[254,128,"9600 baud line 1~"] '128 so as not to add space
pause 100
SEROUT PortB.5,T2400,[254,128,"2400 baud line 1~"]'true
pause 100
serout PortB.4,T9600,[254,128,"9600 baud line 1~"] '128 so as not to add space
pause 1000

each output having a different baudrate.
JS

Pedro Pinto
- 16th February 2008, 22:57
Hi Joe

What Charles say is what i need

i have this for soft usart
bmode con 16780' serin2' 16780 = 2400 true
'
'and set with this the hardware usart for 10466 baudrate, i have not tested, next week
'can i test, and hope that this work
'
' Set receive register to receiver enabled
DEFINE HSER2_RCSTA 90h
' Set baud rate
' Set SPBRG directly (normally set by HSER_BAUD)
DEFINE HSER2_SPBRG 23


Regards
Pedro