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 support@ccsinfo.com

problem with multiple com ports on an 18LF2525

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



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

problem with multiple com ports on an 18LF2525
PostPosted: Sun Apr 01, 2007 12:21 pm     Reply with quote

I am attempting to use two com ports to communicate between a GPS unit and an external terminal. I have written code that works successfully on a 16LF876A device. I want to move the code to an 18LF2525 device.

A portion of the setup is as follows:
Code:

#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=GPS)
#use rs232(baud=9600, parity=N, xmit=PIN_C0, rcv=PIN_C1, bits=8, stream=TERM)


The GPS is initialized to send only the NMEA0183 "GGA" message every 2 seconds by sending the following instruction during init:
Code:

   fprintf(GPS, "@NC 20000000\n\r");    // send command for GGA msg only


The serial interrupt and global are enabled. It is expected that the serial ISR routine will capture the GGA message and process it, similar to the method done by the 16LF876A.

The beginning of the RDA_isr() is as follows:
Code:

// ---- capture GPS data ----
#int_RDA
RDA_isr()
{
   ch = toupper(fgetc(GPS));        // read chars from the gps port
   switch(serState)
   {
   case CMD_STATE:                  // check for line start char ('$')
      if(ch == '$')
      {
         index = 0;
         serState = CHECK_STATE;
      }
      break;

   case CHECK_STATE:                // check for correct line type ('GGA')
...


I don't see the message being received in the serial routine. I placed markers (toggle to an unused I/O pin) in different parts of the routine. It isn't getting into the section where it recognizes the leading '$' character.

I made a simpler version that only echoes the input characters seen in the ISR to the alternate com port. I echoes some characters and then dies.

Is there some subtlety with the 18LF2525 when using multiple com ports?
Does anyone have any other idea of what I could try to isolate this?

Thanks for any help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 01, 2007 1:44 pm     Reply with quote

Quote:

I made a simpler version that only echoes the input characters seen in
the ISR to the alternate com port. It echoes some characters and then dies.

Add the ERRORS parameter to your hardware UART #use rs232() statement.
Does the behavior change if you do that ?

Also, what is your compiler version ?
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

problem with multiple com ports on an 18LF2525
PostPosted: Tue Apr 03, 2007 9:29 pm     Reply with quote

I've never used that pre-processor switch... Could you give me an example of how to use it? I assume you just specify ERRORS at the end of the #USE RS232() definition but how do you check the results? If the com port is dead/dying, how can I print another variable (ERRORS) to the com port?

My compiler version is 3.249.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 9:43 pm     Reply with quote

Could you give me an example of how to use it ?
Quote:
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8, ERRORS, stream=GPS)


It clears overrun errors automatically if they occur, and thus prevents
the hardware UART from locking up.

Add the ERRORS parameter to your hardware UART #use rs232()
statement. Does the behavior change if you do that ?
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

PostPosted: Tue Apr 03, 2007 9:50 pm     Reply with quote

I just added the "ERRORS" switch at the end of the hardware serial port #use rs232() statement and the hardware serial interrupt routine appears to work now!

Thanks very much for your help!
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