CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

2nd USART sends wrong character why?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tonofit



Joined: 23 Jun 2005
Posts: 4

View user's profile Send private message

2nd USART sends wrong character why?
PostPosted: Fri Jun 24, 2005 12:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 24, 2005 1:11 pm     Reply with quote

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)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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