tonofit
Joined: 23 Jun 2005 Posts: 4
|
2nd USART sends wrong character why? |
Posted: Fri Jun 24, 2005 12:32 pm |
|
|
I'm trying to use 2 usarts. I'm outputing a * and % character for a test.
The 1st usart PORT1 is working fine.
The 2nd usart PORT2 is suppose to output a % but is sending a lower case m. Does anyone know if there is a start bit problem with the G port. Looking at the bit pattern it looks like the 1st bit of the character could be a start bit or do I have to configure something more to use the 2nd USART?
Hex code for a % is 0x25
Hex code for a m is 0x6D
Code: | #include <18F8722.h>
#device ICD=TRUE
#fuses HS,NOWDT,PUT,NOBROWNOUT,NOLVP
#define XTAL_FREQ 10000000 // Demo Board PIC18F8722
#use delay(clock=XTAL_FREQ)
#use rs232 (baud=19200, xmit=PIN_C6, rcv=PIN_C7,stream = PORT1)
#use rs232(baud=9600, xmit=PIN_g1,stream=PORT2)
void main()
{
while(1)
{
fputc('*',PORT1);
delay_us(500);
fputc('%',PORT2);
delay_us(500);
}
} |
|
|
tonofit
Joined: 23 Jun 2005 Posts: 4
|
|
Posted: Fri Jun 24, 2005 1:11 pm |
|
|
The answer is that PORT1 has a MAX232 level converter and PORT2 doesn't so the directive INVERT must be included in the directive
#use rs232(baud=9600, xmit=PIN_g1,INVERT,stream=PORT2) |
|