|
|
View previous topic :: View next topic |
Author |
Message |
rs232 problems Guest
|
rs232 problems |
Posted: Wed Sep 29, 2004 12:17 pm |
|
|
I wrote a small application to read from a GPS module and send whatever it reads to the PC.
Code: | #include <16f876.h>
#include <string.h>
#fuses XT, NOPROTECT, BROWNOUT, LVP, NOWDT, PUT
#use delay (clock=4000000)
#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GSM)
#use rs232(baud=4800,parity=N,xmit=PIN_C4,rcv=PIN_C5,bits=8,stream=HOSTPC)
#use rs232(baud=4800,parity=N,xmit=PIN_C2,rcv=PIN_C3,bits=8,stream=GPS)
.
.
fprintf(HOSTPC,"Ready");
.
.
while(1)
{
c = fgetc(GPS);
fputc(c,HOSTPC);
} |
When I run that program "Ready" is displayed correctly on my terminal. When the GPS unit starts to send the NMEA data I start to see garbage on my terminal except for the '$' and ',' characters. Both are displayed correctly and other characters are nothing but garbage.
I connected the GPS unit directly to my PC using max232 and it dumps the NMEA data correctly w/o any problem on my terminal.
One more thing to say, I am using interrupt handler to deal with the GSM stream.
Code: | #INT_RDA
rda()
{
int8 c;
c=fgetc(GSM);
if(c==10)
{
sbuf[scnt-1]=0;
scnt = 0;
sflag=1;
} else
{
sflag = 0;
sbuf[scnt++]=c;
}
} |
Any idea? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Sep 29, 2004 12:46 pm |
|
|
In your interrupt handler, I would try the following just to quit the interrupt handler as soon as posible.
Code: |
#INT_RDA
rda()
{
int8 c;
if(kbhit(GSM))
{
c=fgetc(GSM);
if(c==10)
{
sbuf[scnt-1]=0;
scnt = 0;
sflag=1;
}else
{
sflag = 0;
sbuf[scnt++]=c;
}
}
}
|
best wishes,
Humberto |
|
|
|
|
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
|