View previous topic :: View next topic |
Author |
Message |
StealthMicro
Joined: 10 Apr 2007 Posts: 17
|
Software RS232 Problem. |
Posted: Wed Apr 18, 2007 6:18 pm |
|
|
I am sure this is s newbie mistake on my part...
The relevant code is as follows.
Code: | #use rs232(baud=4800,parity=N,rcv=PIN_D7,bits=8,stream=GPS) // Used to get 4800 NMEA stream from GPS
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=TERM) // Used as output to the terminal
char c;
do
{
if (kbhit(GPS)){
c = fgetc(GPS);
fputc(c, TERM);
}
} while(TRUE); |
When I run the code I get 0x00 back constantly from the GPS serial port with or even without the GPS connected to the board.
I am using v4.032 which is the latest available at time of writing. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
StealthMicro
Joined: 10 Apr 2007 Posts: 17
|
|
Posted: Thu Apr 19, 2007 11:22 am |
|
|
I tried using the invert option with no success.
I am using the Telit GM862 GPS with the USB EVK V3 from Spark Fun and am directly connecting the pins to the Olimex PIC-P40 breakout board. Here is a scope reading from pin D7 directly taken from the pic itself.
Which clearly shows the signal arriving at the PIC. I know it is only coming in at 3V but that according to the PICs datasheet is enough to create a HIGH for the pin.
Just to check things out I modified the code to do the following.
Code: | #use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7,stream=HOSTPC,FORCE_SW)
while(TRUE){
c = fgetc(HOSTPC);
fputc(c, HOSTPC);
} |
And I get nothing which is different from the 0x00 NUL I see constantly without the GPS connected to the PIC-P40 board at all using it as the fgetc source. I am sure it is something that I am doing. But just trying to figure out what that is. Without the FORCE_SW code with the same while statement I get LOCAL ECHO effects which is what I expected. I would think that the FORCE_SW would produce the same result unless I am missing something. |
|
|
StealthMicro
Joined: 10 Apr 2007 Posts: 17
|
|
Posted: Thu Apr 19, 2007 11:29 am |
|
|
As an interesting experiment I tried this code.
Code: | #use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7,stream=HOSTPC,FORCE_SW)
void main()
{
char c;
while(TRUE) {
c=fgetc(HOSTPC);
fputc(c,HOSTPC);
if (c == 'T'){
output_toggle(PIN_A0);
}
}
} |
This code does toggle the LED with a capitol T entered on the keyboard but nothing else but I do not see the character echoed back to the terminal. Strange. It is like the TRANSMIT works but the RECEIVE does not. |
|
|
StealthMicro
Joined: 10 Apr 2007 Posts: 17
|
|
Posted: Thu Apr 19, 2007 11:48 am |
|
|
Okay I moved the terminal over to D2 and D3 and it worked like a charm. So for some reason the FORCE_SW just appears not to work right with this particular combination. So maybe I am reading the data sheet wrong and maybe 3v is not quite enough to trigger a HIGH on the software RS232 connection after all.
What is the favorite LEVEL CONVERTER between 3v and 5v these days? Anyone have a particular circuit they like better then others or a particular IC they prefer over others that comes in a DIP package? |
|
|
StealthMicro
Joined: 10 Apr 2007 Posts: 17
|
|
Posted: Thu Apr 19, 2007 12:49 pm |
|
|
Problem solved. After reviewing the data sheet yet again I noticed that the TTL was able to pick up at around 2.4v but the ST was 0.8 VDD which is about 4.2v which is out of range. By moving the receive over to pin B1 I was able to utilize a TTL input and all started working. I guess it pays to read the data sheet then read it again and again and again. |
|
|
|