View previous topic :: View next topic |
Author |
Message |
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
#use RS232 switching baud rate during execution |
Posted: Sat May 08, 2004 7:19 pm |
|
|
Hi I'm using PCM Version 3.168 with PIC 16F876, doing serial comms with hardware USART.
Is it possible to change baud rates mid program? At the start of the program I set baud rate to 19,200 however I'm wondering if I can switch to 9,600 to send out a few bytes, and them immediatly switch back to 19,200?
Thanks |
|
|
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
|
Posted: Sat May 08, 2004 7:23 pm |
|
|
PS One more thing, it compiles ok, but when I run it, it still transmits at 19,200 bps.
Here is the code snippet
Code: |
if (!datalogging) {
/* Output max value in binary LS Byte then MS Byte at 9,600 bps */
#use rs232(baud=9600, bits=8, parity=N, ERRORS, xmit=PIN_C6, rcv=PIN_C7)
putc (make8 (y_max, 0));
putc (make8 (y_max, 1));
#use rs232(baud=19200, bits=8, parity=N, ERRORS, xmit=PIN_C6, rcv=PIN_C7)
}
|
|
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Sat May 08, 2004 8:18 pm |
|
|
If you are using the hardware UART, you can use the set_uart_speed() function to change the speed on the fly. |
|
|
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
|
Posted: Sat May 08, 2004 8:29 pm |
|
|
Wow so simple, thanks. I never noticed that function in the manual.
Thanks again |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Sat May 08, 2004 9:35 pm |
|
|
Actually that function is not in the official manual, but you can find it in the Readme.txt file in the compiler directory. This files contains information about all the neat functions that have been added since the last manual release. |
|
|
|