|
|
View previous topic :: View next topic |
Author |
Message |
Cheick Guest
|
RS232 Help |
Posted: Thu Feb 03, 2005 7:58 am |
|
|
Hi,
My program seems to be correct but, I do not receive anything the PC to the Pic. It always marks me for A or B the value received 0xFF. Can somebody say to me why? Thank you
#include <18f452.H>
#device adc=8
#fuses NOWDT, NOLVP, PUT, NODEBUG, HS
#use delay (clock=10000000)
#use rs232(BAUD=9600, XMIT=PIN_C6,RCV=PIN_C7,PARITY=N,BITS=8,STREAM = COM_1/*Force_sw,invert*/)
void main()
{
char C;
printf("\rOK!\r\n");
printf(" Copis et Lis ! ;\r\n");
//getc();
while(1)
{
if(kbhit(COM_1))
{
c=getch(COM_1);
fprintf(COM_1," PIC a recu le caractere :'%C'\r\n",c);
fprintf(COM_1," EN ASCII code %C decimale ou en Hex 0x%02X hex\r\n",c,c);
}
}
} |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Feb 03, 2005 8:37 am |
|
|
What compiler version?
Is your RS232 cable correct? How are you driving the cable? Directly or with a level converter like a MAX232? What is at the other end? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Thu Feb 03, 2005 9:04 am |
|
|
Basically you cannot do a putc ( your fprint does many putc transmits) while you are receiving asynchronously..
the reason is as your PIC C is doing the putc the tansmitter can send a char. Now with a hardware buffer on the PIC you can have an unread ( by your program) char in the buffer while a new char is received. You are more than echoing every char so the hardware buffer will be overrun quickly. No delay on the PIC will solve this only delays or synchronization on the transmitter or alternatively a circular receive buffer for your receive code will correct it.
Si mon anglais est un peu complexe je peux essayer d'expliquer en francais si vous voulez |
|
|
|
|
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
|