Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
Changing baud rate on the fly
Posted: Thu Feb 26, 2004 6:04 am
Hi
Can I use the set_baud_rate() to change the baud rate of a software serial port? Or does it only work with the hardware UART?
The manual says it is only for the hardware UART. In an application I have a software and a hardware UART with different stream identifiers, using the set_baud_rate() function with each of the indentifiers results in a different code (as in the .LST file), but it seems the software port doesn't change the speed.
Thanks.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Thu Feb 26, 2004 12:33 pm
Quote:
Can I use the set_baud_rate() to change the baud rate of a software serial port ?
No.
The CCS library code for software USARTs doesn't have the ability
to change the baud rate. The baud rate is determined by inline code
with software delay loops or just NOPs, to create the appropriate
pulse widths. These delays are hard coded at compile time.
The solution is to use a separate #use rs232 statement for each
baudrate that you need for your software USART. This will cause
the compiler to generate a separate set of ASM code for each
baudrate. Here is a post that shows one way to do this:
http://www.pic-c.com/forum/old/messages/3188.html
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum