![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Cheick Guest
|
Rs232 |
Posted: Thu Jan 20, 2005 8:01 am |
|
|
Hi,
I try to make a connection pic PC to post the character on the PC but that does not work. Is what my code is false?
Thanks.
#include <18f452.h>
#fuses NOWDT, NOLVP, PUT, NODEBUG, HS
#use delay (clock=20000000)
#use rs232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7,PARITY=N,BITS=8,STREAM=COM_1)
void main()
{
char c;
fprintf(COM_1,"\rOK!\r\n");
fprintf(COM_1,"lire! ;-)\r\n");
while(1)
{
if(kbhit())
{
c=fgetc(COM_1);
fprintf(COM_1,"PIC a recu les charactere :'%c'\r\n",c);
fprintf(COM_1," ASCII code %d decimal ou 0x%02X hex\r\n",c,c);
}
}
} |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Jan 20, 2005 8:38 am |
|
|
What does your code do wrong? Does it print anything? You may have a problem with kbhit not referring to the stream, try:
if(kbhit(COM_1))
Also tell us what compiler version number you have.
English grammar correction:
"Is what my code is false?" should probably be "Where is my code wrong?". _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Jan 20, 2005 9:43 am |
|
|
In addition to SherpaDoug's question, what are you using for your RS232 to TTL level shifting?
Assuming a MAX232 type chip, is it wired correctly?
Are the voltages on its V+, V- pins correct?
If you aren't using a level shifting chip and just driving the PCs RS232 port then you need to add the INVERT statement to your #use RS232 command.
Another quick suggestion, use the "CODE" button when submitting code on the forum. It keeps your formating rather than left justifying all the lines which makes it a bit hard to read. Click "CODE" then copy your code into the text box and click "CODE" a second time. You should see something like bracketting your code. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|