|
|
View previous topic :: View next topic |
Author |
Message |
Murali.K Guest
|
Two Hardware UARTs |
Posted: Wed Aug 01, 2007 2:06 am |
|
|
Hi,
I need to use two UARTs in my application. I am using PIC18F87J10 which has 2 UARTs.
I have used the following in my code.
#USE RS232(stream=UART1,BAUD=9600, XMIT=PIN_C6,RCV=PIN_C7)
#USE RS232(stream=UART2,BAUD=4800,XMIT=PIN_G1,RCV=PIN_G2)
Both the UARTs are working. I think UART1 is implemented as Hardware UART but UART2 is implemented as software. (no registers of UART2 is initialized)
How to have two hardware UARTs implemented and what is the directive for specific UART( 1 or 2) Tx & Rx
Thanks in advance.
Best Regards
Murali |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Aug 01, 2007 2:40 am |
|
|
Quote: | what is the directive for specific UART( 1 or 2) Tx & Rx | Pass the stream you want to access as a parameter to the fputc() and fgetc() functions. Give the streams more meaningful names than UART1 and UART2.
The functions getc/putc don't have a stream identifier and default to STDIN. This might be the reason why you don't see code generated for the second stream.
I also would add the ERRORS directive to the RS232 declaration to prevent the UART from stalling in error situations.
Code: | #USE RS232(stream=PC, BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)
#USE RS232(stream=GPS, BAUD=4800, XMIT=PIN_G1, RCV=PIN_G2, ERRORS)
void main()
{
int8 data;
// Copy all data received from the GPS device to the PC.
while(TRUE)
{
data = fgetc(GPS);
fputc(data, PC);
}
} |
In case the problem persists, what is your compiler version number? |
|
|
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|