View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 11, 2005 12:45 pm |
|
|
Thanks. It might be tonight or tomorrow morning before I can test this. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 11, 2005 10:29 pm |
|
|
I looked at your PicBasic-Pro program. It's doing something quite
different than the character echo program in C. The PBP program
is reading an entire string and "camping on" the serial input pin (C7)
until that string is received. Then it outputs the entire string to
the Debug pin (D0).
That would certainly work, because it's not going to miss any incoming
characters.
I think if you just write up the same thing in C, it will work too. |
|
|
ramans
Joined: 10 Oct 2005 Posts: 9
|
|
Posted: Wed Oct 12, 2005 12:47 pm |
|
|
Isn't that what the gets/puts C program we tried earlier did? that did not work.
-R |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 12, 2005 12:56 pm |
|
|
I will test it later today in hardware and let you know. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 13, 2005 1:54 am |
|
|
I think the problem is caused by a bug in the CCS library code for
a software UART when used with fgets(), and a high oscillator
frequency and a low baud rate. I think CCS is using the FSR
register as the MSB of an internal delay loop, and they're trashing it.
I'll report the bug to CCS as soon as I document it better.
As a work-around, you need to create your own version of
fgets() in code. I've done that in the sample program below.
The code as written just emulates fgets(), but it could be improved
so that a long input string doesn't blow past the end of the buffer.
I know this sample program doesn't fit your situation exactly,
since it uses the same baud rate for the gps and dbg streams.
But I don't have the splitter cable with me right now, and I'm
pretty sure I've found the bug and a work-around, so I'll post
this tonight.
Code: |
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use rs232(baud=2400, xmit=PIN_C6, stream=DBG)
#use rs232(baud=2400, rcv=PIN_C7, stream=GPS)
//======================================
void main()
{
char c;
char str[80];
char *ptr;
while(1)
{
// The following code emulates the fgets() function,
// without causing the bug.
ptr = str; // Get pointer to start of string buffer
while(1)
{
c = fgetc(gps); // Get a char
if(c == 0x0d) // Is it a message terminator ?
break; // Break if so
else
*ptr++ = c; // Otherwise, put char in buffer
}
*ptr = 0; // If done, write string terminator
// fgets(str, GPS); // Comment this line out.
fputs(str, DBG);
}
} |
|
|
|
ramans
Joined: 10 Oct 2005 Posts: 9
|
|
Posted: Thu Oct 13, 2005 5:28 pm |
|
|
Thanks I'll give this a try! |
|
|
ramans
Joined: 10 Oct 2005 Posts: 9
|
|
Posted: Mon Oct 17, 2005 10:59 am |
|
|
Bingo! That works. Cool thank you, and let me know if you hear of a fix for the initial bug! |
|
|
|