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 support@ccsinfo.com

RS232 Communication Problem

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



Joined: 25 Sep 2003
Posts: 7
Location: Uniontown, PA

View user's profile Send private message Send e-mail Visit poster's website

RS232 Communication Problem
PostPosted: Wed Jan 07, 2004 1:31 pm     Reply with quote

I am trying to get the serial communications to work correctly on a 16F876. I am perplexed since this seems like such a simple thing to do.

My Code Looks like:
Code:

#include <16f876.h>
#fuses XT,NOWDT,NOPROTECT, NOPUT, NOBROWNOUT
#use delay(clock=4000000)

#use rs232(baud=2400, PARITY=N, BITS=8, xmit=PIN_C6, rcv=PIN_C7)


#include <stdlib.h>



void main()

   while(TRUE)
   {
      puts("Hello World");
   }
}


I do get output on the PC, but it appears garbled. I have checked and re-checked the PC's settings and have tried 2400 and 9600 baud rates. I am currently using a 4MHz RC oscillator for the clock timing, but have also tried a 20MHz crystal with the same results. The results look like:

еееееехыееееееo5''!┐Q!'7еееееехыееееееo5''!┐Q!'7еееее

Any ideas would really be appreciated.

Thanks!
_________________
Greg
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Jan 07, 2004 1:53 pm     Reply with quote

What kind of level translator are you using to go from logic level to +-15V?
gbaugh



Joined: 25 Sep 2003
Posts: 7
Location: Uniontown, PA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Jan 07, 2004 1:59 pm     Reply with quote

None. I have recently moved from PicBasic to the CCS compiler. With PBP, no level translator was required to tx/rx RS232 data so I figured that the same hardware would work with CCS. Am I incorrect in thinking this?
_________________
Greg
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Jan 07, 2004 2:07 pm     Reply with quote

gbaugh wrote:
None. I have recently moved from PicBasic to the CCS compiler. With PBP, no level translator was required to tx/rx RS232 data so I figured that the same hardware would work with CCS. Am I incorrect in thinking this?


If you use other pins than the hardware USART you may invert the signal and get back to where you were with PicBasic. Your PC232 port may have no problem with logic levels but will need to have the signal inverted.
gbaugh



Joined: 25 Sep 2003
Posts: 7
Location: Uniontown, PA

View user's profile Send private message Send e-mail Visit poster's website

Thanks!
PostPosted: Wed Jan 07, 2004 2:23 pm     Reply with quote

Thanks for your help. It works now.
_________________
Greg
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 07, 2004 3:09 pm     Reply with quote

You could put a soft usart on the hardware usart pins if you had to,
by using the method in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=17803
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