CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Software RS232 Problem.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
StealthMicro



Joined: 10 Apr 2007
Posts: 17

View user's profile Send private message

Software RS232 Problem.
PostPosted: Wed Apr 18, 2007 6:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 19, 2007 4:22 am     Reply with quote

Read this thread about connecting to a GPS. Read the posts about
the proper cable connections and the use of the INVERT option for
a software UART.
http://www.ccsinfo.com/forum/viewtopic.php?t=25249highlight=gps+invert&start=15

If that thread doesn't help then post the manufacturer and model number
of your GPS.
StealthMicro



Joined: 10 Apr 2007
Posts: 17

View user's profile Send private message

PostPosted: Thu Apr 19, 2007 11:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 19, 2007 11:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 19, 2007 11:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 19, 2007 12:49 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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