Change Baud rate
10gigbill
Posts: 79
I am building a serial test generator to send out serial commands. I would like to have several baud rates (say from reading a dip sw) Since "Baud" is a constant, how do I get around this? (without writing different subs for each baud rate)
Comments
It could be a variable.
baudrate var Word
baudrate = 9600
SEROUT Sio, Baudrate, ["Bingo!"]
baudrate = 4800
SEROUT Sio, Baudrate, ["Bango!"]
While I've never tried this, take a look in the manual at the second example in the INTERRUPT command. It shows how to receive into a buffer using ASM code. It further shows the baud rate as a constant, but it would not be hard to modify this for a variable baud rate and for sedning instead of receiving. There are all SX library returns for complete UART functionality and a lot more here:
http://www.piclist.com/techref/scenix/lib/io/osi2/serial/rs232_sx.htm
I was looking at my XBee remote control programming from then.
The baudrate doesn't have to be a declared CONstant (it's a "string constant").
SEROUT xmt_pin, T9600, "!"
The value to be transmitted, that in quotes, could be a byte variable instead.
Read your DIP switches before you transmit and branch to a FUNC or SUB with the desired baudmode plugged in?
I think that might be the way to go. I'll plug that in and see.
Bill