View previous topic :: View next topic |
Author |
Message |
Max1988
Joined: 18 May 2010 Posts: 2
|
Software UART setup_uart_speed |
Posted: Tue May 18, 2010 7:16 am |
|
|
Hello,
I use a hardware and software RS232 on my PIC18F2480.
I want to change the Baudrate during program execution.
For the hardware I take the function setup_uart_speed(),
but this don't work with software UART.
How can I realize this with a software UART?
Regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 18, 2010 12:12 pm |
|
|
The baud rate for the software UART is hard-coded at compile-time.
It's not configurable at runtime.
Therefore, to use two different baud rates, you need to create two
#use rs232() statements, and define a Stream name for each statement.
Then in your program, use fgetc(), fputc(), fprintf(), etc., and put in the
stream that you want to use. The stream cannot be a variable. It must
be a constant. So you will need to use an if() statement to decide which
fputc() statement to call. Each fputc() statement will have a different stream. |
|
|
Max1988
Joined: 18 May 2010 Posts: 2
|
|
Posted: Tue May 18, 2010 1:17 pm |
|
|
Thank you very much.
It works perfectly!!!!
Regards |
|
|
|