View previous topic :: View next topic |
Author |
Message |
gbaugh
Joined: 25 Sep 2003 Posts: 7 Location: Uniontown, PA
|
RS232 Communication Problem |
Posted: Wed Jan 07, 2004 1:31 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Jan 07, 2004 1:53 pm |
|
|
What kind of level translator are you using to go from logic level to +-15V? |
|
![](templates/subSilver/images/spacer.gif) |
gbaugh
Joined: 25 Sep 2003 Posts: 7 Location: Uniontown, PA
|
|
Posted: Wed Jan 07, 2004 1:59 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Wed Jan 07, 2004 2:07 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
gbaugh
Joined: 25 Sep 2003 Posts: 7 Location: Uniontown, PA
|
Thanks! |
Posted: Wed Jan 07, 2004 2:23 pm |
|
|
Thanks for your help. It works now. _________________ Greg |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
|