View previous topic :: View next topic |
Author |
Message |
starfire151
Joined: 01 Apr 2007 Posts: 195
|
problem with multiple com ports on an 18LF2525 |
Posted: Sun Apr 01, 2007 12:21 pm |
|
|
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
|
|
Posted: Sun Apr 01, 2007 1:44 pm |
|
|
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
|
problem with multiple com ports on an 18LF2525 |
Posted: Tue Apr 03, 2007 9:29 pm |
|
|
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
|
|
Posted: Tue Apr 03, 2007 9:43 pm |
|
|
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
|
|
Posted: Tue Apr 03, 2007 9:50 pm |
|
|
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! |
|
|
|