View previous topic :: View next topic |
Author |
Message |
Seidleroni Guest
|
How to use multiple UART (or EUSART) |
Posted: Mon Apr 02, 2007 8:01 am |
|
|
I'm using the PIC18F2620, and I can use it with my code no problem with the standard receive and transmit pins (C6 and C7), but if I try to use it on two different pins (B5 and B6), it gives me an error on the line:
set_uart_speed(2400);
Is there something else I need to do when switching from the standard hardware UART pins to other pins?
Thanks!
Seidleroni |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 02, 2007 9:07 am |
|
|
With the standard pins (C6 and C7) the compiler will select the internal hardware UART. When you select B5 and B6 the compiler will generate a software UART.
Check the manual, set_uart_speed() is only allowed for changing the baudrate of the _hardware_ UART, it is not allowed for a software based UART.
Last edited by ckielstra on Mon Apr 02, 2007 9:07 am; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Mon Apr 02, 2007 9:07 am |
|
|
Read the manual entry for 'set_uart_speed'. Noth that it says:
"Changes the baud rate of the built-in hardware RS232 serial port at run-time".
Note the word 'hardware'...
You cannot change the speed of a 'soft' UART. The software UART, is done by generating specific code for the speed requested.
If you want two speeds on a software UART, then declare two 'streams' on the pins with different baud rates, and select the stream to get the required rate (this results in two separate routines being generated).
Best Wishes |
|
|
|