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

Unidentified Identifier: RS232_ERRORS

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



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

Unidentified Identifier: RS232_ERRORS
PostPosted: Fri Jan 13, 2006 7:50 am     Reply with quote

Hi all,

I've progressed onto learning about serial interupts and circular buffers and found a piece of code that checks the framing error bit of the rs232_error register, but when I compile the code I get the 'Unidentified Identifier' error message. The first part of the interupt routine is as follows:

Code:

#int_rda

void SerialInterrupt ( void )

char cChar;

    if ( RS232_ERRORS & 0x04 )  // get framing error bit from Rx status reg
        {
        cRxErrorFlag = ON;
        }
    cChar = getchar();       // get char from UART, clear any errors

etc...


Do I have to define/declare the use of the RS232_ERRORS register somewhere at the beginning of the code? Can someone point me to any information on how to access/use this register?
dyeatman



Joined: 06 Sep 2003
Posts: 1938
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Jan 13, 2006 10:31 am     Reply with quote

This has been discussed numerous times on this forum. I appreciate that you are trying to learn but please try searching the forum before asking a question to see if it has already been answered. Many times you will get much more information and example code as a bonus!

Take a look at the link below for your answer..

http://www.ccsinfo.com/forum/viewtopic.php?t=22876&highlight=rs232errors

Regards
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Fri Jan 13, 2006 1:25 pm     Reply with quote

dyeatman wrote:
This has been discussed numerous times on this forum. I appreciate that you are trying to learn but please try searching the forum before asking a question to see if it has already been answered. Many times you will get much more information and example code as a bonus!

Take a look at the link below for your answer..

http://www.ccsinfo.com/forum/viewtopic.php?t=22876&highlight=rs232errors

Regards


Believe me I have searched and searched and I never post until I am really stuck. I have been programming for some time now and am not a newbie, just new to this particular area.

I know this has been discussed many times before and I have read *both* of the threads that you have suggested prior to posting, but it still hasn't answered my question. All of the suggestions that have been offered in those threads haven't helped me.

Can you (or anyone else) point me to where the RS232_ERRORS is discussed in the manual or some other source?

BTW: I am using the latest version of the compiler. I can post the entire code if necessary.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 13, 2006 2:02 pm     Reply with quote

Are you using #case with RS232_ERRORS in upper case ?
That will cause the "undefined identifier error, because CCS
uses lower case for that symbol. See the symbol table below:
Code:

SYMBOL TABLE
  LABEL                             VALUE

PSP_DATA                          00000008
CCP_1_LOW                         00000015
CCP_1                             00000015
CCP_1_HIGH                        00000016
CCP_2_LOW                         0000001B
CCP_2                             0000001B
CCP_2_HIGH                        0000001C
rs232_errors                      00000020
main.c                            00000021
_RETURN_                          00000078
main                              00000004

Quote:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#case // This will cause the "undefined identifier" error
//============================
void main()
{
char c;

c = RS232_ERRORS;


while(1);
}
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri Jan 13, 2006 2:59 pm     Reply with quote

Quote:

Can you (or anyone else) point me to where the RS232_ERRORS is discussed in the manual or some other source?

Well, this is not the only issue that is not clearly discussed in the manual nor in any source.
CCS Compiler has a lot of built-in functions whose generated object code is not visible to
the user.
Anyway I will try to clarify this issue. When you include the parameter ERRORS in the
pre-processor directive #use RS232(..) the compiler generate extra code to clear the
detected errors in the RCSTA register. The capability of detecting an error is a PIC feature,
not a compiler capability.
PIC microcontrollers with built in Serial Controller Interface has this feature
because its data recovery block operate at 16x times the baud rate so it can recover
enough info to detect unexpected levels detected in every single bit of the arraiving
character, namelly overrun errors.
Normally this is done in the ninth bit (normally the STOP bit for an 8 bit wide) the
compiler make a copy of the RCSTA (Receiver Status and Control Register)
in the variable rs232_errors and test the bit 1 (OERR) to determine if any error
occurred during the char reception, if any error occurred, set the enable bit CREN.

The action of the CREN bit is not trivial:
CREN: Continuous Receive Enable bit.
1= Enable continuous receive
0= Disable continuous receive

If you do not include the ERRORS parameter in the #use RS232(..) directive,
the ocurrence of the first error will clear the CREN and block the receiver.

Including ERRORS the compiler generate this extra code to handle the detected errors.
Code:
 

D <! .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
D <! 00A0:  BTFSS  PIR1.5
D <! 00A2:  BRA    00A0
D <! 00A4:  MOVFF  RCSTA,rs232_errors
D <! 00A8:  MOVFF  RCREG,01
D <! 00AC:  BTFSS  rs232_errors.1
D <! 00AE:  BRA    00B4
D <! 00B0:  BCF    RCSTA.4
D <! 00B2:  BSF    RCSTA.4
D <! 00B4:  NOP
D <! 00B6:  GOTO   00BC (RETURN)




Humberto
Ttelmah
Guest







PostPosted: Fri Jan 13, 2006 3:55 pm     Reply with quote

Generally, CREN, is not cleared by an error.
The error flags themselves 'block' reception, and it is the act of clearing CREN, that clears the errors. Hence the bit has to be cleared, and then reset.
It may just be 'worth' being aware of this difference, if handling any of this yourself.

Best Wishes
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Sat Jan 14, 2006 10:47 am     Reply with quote

Hi Guys,

This is all very useful, constructive information, just what I needed - many thanks.

I haven't tried using the #case pre-processor yet but I am using ERRORS in #use rs-232. I did try rs232_errors in uppper and lower case but no difference there.

Here is the piece of code that I have been learning from. It's for a GPS compass. Unfortunately I can't remember who wrote it, so I can't credit them. They did publish it on the web for people to use, so I feel it's ok to post the whole thing here. If you do recognise the code, then an eplanation of the use of the rs232_errors variable in the code would be very useful (or anyone else who can comment on it!).


Code:


/****************************************************************************
compass.c

This program receives NMEA-0183 heading data from a GPS
and displays it on an array of LEDs.


                   +5
                    |
                    14
                ----------
               |          |-6----- N
    ~SerIn --7-|          |-9----- NE
               |          |-10---- E
       XTAL-15-|  16F628  |-11---- SE
       XTAL-16-|          |-2----- S
       CLK -12-|          |-1----- SW
      DATA -13-|          |-18---- W
      MCLR --4-|          |-17---- NW
                ----------
                    5
                    |        CLK, DATA, MCLR are optional programming port.
                   Gnd

***************************************************************************/
#case
#include <16F628.h>
#include <jonsinc.h>

#define EOF             0x00
#define COMMA           ','
#define CR              13
#define SPACE           ' '
#define PERIOD          '.'
#define DOLLAR          '$'
#define NULL            0
#define GPRMC_CODE      75
#define RX_BUFFER_SIZE  70
#define LED_N           PIN_B0
#define LED_NE          PIN_B3
#define LED_E           PIN_B4
#define LED_SE          PIN_B5
#define LED_S           PIN_A3
#define LED_SW          PIN_A2
#define LED_W           PIN_A1
#define LED_NW          PIN_A0
#define ROTATE_MS       30
#define RX_IN           PIN_B1
#define PROG_CLK        PIN_B6
#define PROG_DAT        PIN_B6
#define PROG_MCLR       PIN_A5

#separate char GetField ( void );
#separate void AllOff ( void );
#separate void GetHeading ( void );
#separate void DisplayHeading ( void );
#separate long TrueToMag ( long iH );
#separate long FieldFiveToLong ( void );
#separate void InitRxBuffer ( char cCode );
#separate char GetRxChar ( void );

#fuses HS, NOPROTECT, PUT, NOWDT, BROWNOUT, NOLVP, NOCPD, NOMCLR

#use standard_io ( A )
#use standard_io ( B )
#use delay ( clock = 8000000 )
#use rs232 ( baud=4800, xmit=PIN_B2, rcv=PIN_B1, ERRORS )    // XMIT must be assigned to enable hardward USART

static char cC [ 10 ];      // local buffer
static char cTimeOut;
static char cRxBuffer [ RX_BUFFER_SIZE ];    // Fifo
static char cRxByteCnt;         // Number of bytes in the recv fifo
static char *cRxBufferWritePtr;    // Pointers for the Rx buffer
static char *cRxBufferReadPtr;
static char cRxIsrState, cRxMsgTypeReceived, cRxMsgTypeDesired;
static char cRxMsgReady, cReceiveFlag;
static long iVar, iHdg;
static char cRxErrorFlag, cVarDir, cError;

/*******************************************************************/

#int_rtcc
void Timer0Interrupt ( void )
    {
    // Gets here every 16.52mS
    // Handles data timeout
    if ( cTimeOut != 0 )
        {
        cTimeOut--;
        }
    }

#int_rda
void SerialInterrupt ( void )
    {
    /*
    Reads incoming data from the USART and puts in in a rolling buffer
    ( but in this application, it should never roll.)
    If the buffer is full, this routine just discards the received byte.
    Not checking the LRC byte at the end of the NMEA-0183 sentence.
    */
    char cChar;

    if ( rs232_errors & 0x04 )  // get framing error bit from Rx status reg
        {
        cRxErrorFlag = ON;
        }
    cChar = getchar();       // get char from UART, clear any errors
    if ( cRxByteCnt == RX_BUFFER_SIZE ) // is recv fifo full ???
        {
        goto done;
        }
    switch ( cRxIsrState )
        {
        case 0:
            {
            if ( cChar == DOLLAR )  // if start of NMEA0183 message
                {
                cRxByteCnt = 0;     // reset byte count
                cReceiveFlag = OFF;     // default to off
                cRxMsgTypeReceived = NULL;  // set hashed value to null
                cRxIsrState++;                 // next state
                }
            break;
            }
        case 1:                           // five type characters to obtain
        case 2:
        case 3:
        case 4:
        case 5:
            {
            cRxMsgTypeReceived ^= cChar;      // hash in msg type
            if ( cRxIsrState++ == 5 )        // if time to check message type
                {
                if ( cRxMsgTypeReceived == cRxMsgTypeDesired )  // if good
                    {
                    cReceiveFlag = YES;            // enable receiving
                    cRxBufferWritePtr = cRxBuffer;    // reset to beginning of buffer
                    }
                else                    // don't want this message
                    {
                    cRxIsrState = 0;    // reset to look for next msg
                    }
                }
            break;
            }
        case 6:
            {
            /* Case 6 skips the comma character following msg type */
            cRxIsrState++;
            break;
            }
        default:                          // remainder of characters
            {
            if ( cReceiveFlag == YES )        // if this message is wanted
                {
                *cRxBufferWritePtr = cChar;     // put char in fifo
                cRxBufferWritePtr++;            // increment pointer
                if ( cRxBufferWritePtr == ( cRxBuffer + RX_BUFFER_SIZE ) ) // pointer past end ?
                    {
                    cRxBufferWritePtr = cRxBuffer;      // set pointer to start of fifo
                    }
                cRxByteCnt++;              // Increment byte count
                if ( cChar == CR )
                    {
                    cRxMsgReady = YES;         // signal that message is ready
                    cReceiveFlag = NO;      // no more receive
                    }
                }
            }
        }
    done:;               // label
    }

/*******************************************************************/

void main ( void )
    {
    char cX;

    /* INITIALIZE */
    output_float ( RX_IN );             // ensure Rx input is HiZ
    output_float ( PROG_CLK );
    output_float ( PROG_DAT );
    output_float ( PROG_MCLR );

    // SETUP TIMER 0
    // Need 8-bit Timer0 to roll over every 13mS, approximately.
    // Roll time = 256 * 1 / ( clock_freq / prescaler setting / 4 )
    setup_counters ( RTCC_INTERNAL, RTCC_DIV_128 );   // ~13mS timer wrap

    /* INTERRUPTS */
    enable_interrupts ( INT_TIMER1 );   // enable Timer1 interrupt
    enable_interrupts ( INT_RTCC );     // enable Timer0 interrupt
    enable_interrupts ( INT_RDA );      // enable serial interrupt
    enable_interrupts ( GLOBAL );       // enable all interrupts

    /* VARIABLES */
    iVar = NULL;                        // default, no variation yet
    cVarDir = SPACE;                    // default, no variation yet
    cRxErrorFlag = OFF;

    for ( cX = 0; cX < 5; cX++ )
        {
        output_low ( LED_NW ); output_high ( LED_N ); delay_ms ( ROTATE_MS );
        output_low ( LED_N ); output_high ( LED_NE ); delay_ms ( ROTATE_MS );
        output_low ( LED_NE ); output_high ( LED_E ); delay_ms ( ROTATE_MS );
        output_low ( LED_E ); output_high ( LED_SE ); delay_ms ( ROTATE_MS );
        output_low ( LED_SE ); output_high ( LED_S ); delay_ms ( ROTATE_MS );
        output_low ( LED_S ); output_high ( LED_SW ); delay_ms ( ROTATE_MS );
        output_low ( LED_SW ); output_high ( LED_W ); delay_ms ( ROTATE_MS );
        output_low ( LED_W ); output_high ( LED_NW ); delay_ms ( ROTATE_MS );
        }
    output_low ( LED_NW );

    /* MAIN LOOP */
    while ( TRUE )
        {
        cTimeOut = 242;                 // 242 * 0.0165mS = 4 seconds
        cRxErrorFlag = OFF;             // default to off
        cError = OFF;
        InitRxBuffer( GPRMC_CODE );     // set code and turn on serial interrupt
        while ( ( cRxMsgReady == NO ) && ( cTimeOut != 0 ) );   // wait for RMC sentence
        //disable_interrupts ( INT_RDA ); // ignore rest of messages
        if ( ( cTimeOut != 0 ) && ( cRxErrorFlag == OFF ) )   // if no errors
            {
            GetHeading();               // get heading and variation
            AllOff();                   // turn all LED's off
            if ( cError == OFF )
                {
                DisplayHeading();           // display heading
                }
            }
        else
            {
            AllOff();                   // error, data timeout or framing error
            }
        //enable_interrupts ( INT_RDA );  // enable Rx again
        }
    }

/******************************************************************/

#separate void GetHeading ( void )
    {
    GetField();                     // skip UTC
    GetField();                     // A = OK, V = warning
    if ( cC [ 0 ] == 'A' )          // if valid
        {
        GetField();                 // skip LAT
        GetField();                 // skip N/S
        GetField();                 // skip LON
        GetField();                 // skip E/W
        GetField();                 // skip SPD
        GetField();                 // get HDG
        iHdg = FieldFiveToLong();   // convert
        GetField();                 // skip FIX DATE
        GetField();                 // get MAG VAR
        iVar = FieldFiveToLong();   // convert
        GetField();                 // get EW variation direction
        cVarDir = cC [ 0 ];         // save variation direction
        iHdg = TrueToMag ( iHdg );  // factor variation into heading
        }
    else
        {
        cError = ON;                // error, corrupted data from satellite
        }
    }

#separate void AllOff ( void )
    {
    output_low ( LED_N );
    output_low ( LED_NE );
    output_low ( LED_E );
    output_low ( LED_SE );
    output_low ( LED_S );
    output_low ( LED_SW );
    output_low ( LED_W );
    output_low ( LED_NW );
    }

#separate void DisplayHeading ( void )
    {
    if ( ( ( iHdg > 337 ) && ( iHdg <= 359 ) ) || ( ( iHdg >= 0 ) && ( iHdg <= 23 ) ) )     // N
        {
        output_high ( LED_N );
        }
    if ( ( iHdg > 23 ) && ( iHdg <= 68 ) )       // NE
        {
        output_high ( LED_NE );
        }
    if ( ( iHdg > 68 ) && ( iHdg <= 113 ) )      // E
        {
        output_high ( LED_E );
        }
    if ( ( iHdg > 113 ) && ( iHdg <= 158 ) )     // SE
        {
        output_high ( LED_SE );
        }
    if ( ( iHdg > 158 ) && ( iHdg <= 203 ) )     // S
        {
        output_high ( LED_S );
        }
    if ( ( iHdg > 203 ) && ( iHdg <= 248 ) )     // SW
        {
        output_high ( LED_SW );
        }
    if ( ( iHdg > 248 ) && ( iHdg <= 293 ) )     // W
        {
        output_high ( LED_W );
        }
    if ( ( iHdg > 293 ) && ( iHdg <= 337 ) )     // NW
        {
        output_high ( LED_NW );
        }
    }

#separate long FieldFiveToLong ( void )
    {
    /* Converts ABC.D to long ABC, rounds fraction part up or down */
    long iX;

    iX = 100 * ( long ) ( cC [ 0 ] - 0x30 );
    iX += 10 * ( long ) ( cC [ 1 ] - 0x30 );
    iX += ( long ) ( cC [ 2 ] - 0x30 );
    if ( ( cC [ 3 ] == PERIOD ) && ( cC [ 4 ] >= '5' ) )
        {
        iX++;           // round up
        }
    return ( iX );
    }

#separate long TrueToMag ( long iH )
    {
    /* Magnetic variation information comes from the RMC sentence */

    if ( cVarDir == 'W' )
        {
        iH += iVar;
        }
    else
        {
        if ( iH >= iVar )
            {
            iH -= iVar;     // OK as-is
            }
        else
            {
            iH = iH + 360 - iVar;   // correct for below zero
            }
        }
    if ( iH >= 360 )
        {
        iH -= 360;
        }
    return ( iH );
    }

#separate char GetField ( void )
    {
    char cX, cIndex;

    // Get next field from cRxBuffer and put in cC buffer.
    cX = NULL;
    cIndex = 0;
    while ( cTimeOut != 0 )
        {
        cX = GetRxChar();
        if ( ( cX == COMMA ) || ( cX == CR ) )
           {
           break;
           }
        cC [ cIndex++ ] = cX;
        }
    cC [ cIndex ] = EOF;
    return ( cIndex );         // return number of characters in field
    }

/* RS232 FUNCTIONS ================================================== */

#separate void InitRxBuffer ( char cCode )
    {
    disable_interrupts ( INT_RDA );
    cRxBufferWritePtr = cRxBuffer;      // point to beginning of buffer
    cRxBufferReadPtr = cRxBuffer;
    cRxByteCnt = 0;
    cRxIsrState = 0;
    cRxMsgReady = NO;
    cRxMsgTypeDesired = cCode;
    enable_interrupts ( INT_RDA );
    }

#separate char GetRxChar ( void )
    {
    // Get the next available byte in the recv fifo.
    // Call this function ONLY if the recv fifo contains data.
    char cValue;

    cValue = 0;
    if ( cRxByteCnt > 0 )       // For safety, check if there is any data
        {
        cValue = *cRxBufferReadPtr++;     // Read byte from fifo
        if ( cRxBufferReadPtr == ( cRxBuffer + RX_BUFFER_SIZE ) ) // Did tail ptr wrap ?
            {
            cRxBufferReadPtr = cRxBuffer;    // If so, reset it to start of buffer
            }
        cRxByteCnt--; // Decrement byte count
        }
    return ( cValue );
    }



Cheers,
Ed
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Jan 14, 2006 11:44 am     Reply with quote

Quote:

Here is the piece of code that I have been learning from. It's for a GPS compass. Unfortunately I can't remember who wrote it, so I can't credit them.

This code must be credited to Jon Fick (Westford MicroSystems).


I compiled the code as is, except that I add the directive for a pointer of 16 bit as follow:

#case
#include <16F628.H>
#device *=16
#include <jonsinc.h>

Following I post the code involved with rs232_errors:

Code:
.................... #use rs232 ( baud=4800, xmit=PIN_B2, rcv=PIN_B1, ERRORS )    // XMIT must be assigned to enable hardward USART
*
0040:  BTFSS  PIR1.5
0041:  GOTO   040
0042:  MOVF   RCSTA,W
0043:  MOVWF  rs232_errors
0044:  MOVF   RCREG,W
0045:  MOVWF  @78
0046:  BTFSS  rs232_errors.1
0047:  GOTO   04A
0048:  BCF    RCSTA.4
0049:  BSF    RCSTA.4
004A:  NOP
004B:  GOTO   051 (RETURN)
*


You will see clearly:

0042: MOVF RCSTA,W
0043: MOVWF rs232_errors


where the compiler make a copy of RCSTA.

Then in the INT_RDA, Jon makes -by hand- a test of bit 2 (FERR) of the copy of RCSTA
looking for a frame error:
if ( rs232_errors & 0x04 ) or
BTFSS rs232_errors.2

Note that for test a bit he uses the same variable that CCS does internally,
just for saving RAM, wich is a good practice. Otherwise he would create a new one
and this would not make sense.

Code:

....................     if ( rs232_errors & 0x04 )  // get framing error bit from Rx status reg
*
004C:  BTFSS  29.2
004D:  GOTO   050
....................         {
....................         cRxErrorFlag = ON;
004E:  MOVLW  01
004F:  MOVWF  cRxErrorFlag
....................         }



The sym list shows the name of the variable living at address 029.

Code:

027     @INTERRUPT_AREA
028     @INTERRUPT_AREA
029     rs232_errors
02A-033 cC
034     cTimeOut
035     cRxByteCnt



Humberto
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Sun Jan 15, 2006 4:02 pm     Reply with quote

Hi Humberto,

#device *=16 did the trick - can't believe I didn't think of that. Program runs fine now. I tried converting it to run on an 'F877A using a MAX232 and it's UART, but I can't get it to display the heading when I introduce a GPS signal. I know the GPS signal is valid and that the com port/coms connections work as they have been proven before. Is there anything I could be doing wrong when changing over to an F877A? Code changes:

Code:

#case
#include <16F877A.h>
#device *=16
#include <jonsinc.h>


#define EOF             0x00
#define COMMA           ','
#define CR              13
#define SPACE           ' '
#define PERIOD          '.'
#define DOLLAR          '$'
#define NULL            0
#define GPRMC_CODE      75
#define RX_BUFFER_SIZE  70
#define LED_N           PIN_D0
#define LED_NE          PIN_D1
#define LED_E           PIN_D2
#define LED_SE          PIN_D3
#define LED_S           PIN_D4
#define LED_SW          PIN_D5
#define LED_W           PIN_D6
#define LED_NW          PIN_D7
#define ROTATE_MS       30
//#define RX_IN           PIN_B1
//#define PROG_CLK        PIN_B6
//#define PROG_DAT        PIN_B6
//#define PROG_MCLR       PIN_A5

#separate char GetField ( void );
#separate void AllOff ( void );
#separate void GetHeading ( void );
#separate void DisplayHeading ( void );
#separate long TrueToMag ( long iH );
#separate long FieldFiveToLong ( void );
#separate void InitRxBuffer ( char cCode );
#separate char GetRxChar ( void );

#fuses HS, NOPROTECT, PUT, NOWDT, BROWNOUT, NOLVP, NOCPD //NOMCLR

#use standard_io ( A )
#use standard_io ( B )
#use delay ( clock = 8000000 )
#use rs232 ( baud=4800, xmit=PIN_C6, rcv=PIN_C7, ERRORS )    // XMIT must be assigned to enable hardward USART

static char cC [ 10 ];      // local buffer
static char cTimeOut;
static char cRxBuffer [ RX_BUFFER_SIZE ];    // Fifo
static char cRxByteCnt;         // Number of bytes in the recv fifo
static char *cRxBufferWritePtr;    // Pointers for the Rx buffer
static char *cRxBufferReadPtr;
static char cRxIsrState, cRxMsgTypeReceived, cRxMsgTypeDesired;
static char cRxMsgReady, cReceiveFlag;
static long iVar, iHdg;
static char cRxErrorFlag, cVarDir, cError;

/*******************************************************************/
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 9:01 am     Reply with quote

Quote:

Program runs fine now.


Do you mean that the program compiled succesfully or the whole hardware + firmware
is running OK receiving GPS string and showing heading info?

Quote:

I tried converting it to run on an 'F877A using a MAX232 and it's UART, but I can't get it to display the heading when I introduce a GPS signal.


I can't see why it doesn't work in the 'F877A'. Did you make a simple test in the 'F877A' hardware
to be sure that it is properly wired and the oscillator working ?


Humberto
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 9:35 am     Reply with quote

Humberto wrote:


Do you mean that the program compiled succesfully or the whole hardware + firmware
is running OK receiving GPS string and showing heading info?



It compiles and runs, but the program doesn't display the heading. When I send a gps stream of data, the D0 LED lights up. And when I stop the GPS signal, D0 goes out. That's it.

Humberto wrote:

I can't see why it doesn't work in the 'F877A'. Did you make a simple test in the 'F877A' hardware
to be sure that it is properly wired and the oscillator working ?


I know the harware is fine as I have it running on a dev board that I have been using for a long time now. Also, when the program runs you can see the 'direction' LEDs scroll as per this bit of code:

Code:

 for ( cX = 0; cX < 5; cX++ )
        {
        output_low ( LED_NW ); output_high ( LED_N ); delay_ms ( ROTATE_MS );
        output_low ( LED_N ); output_high ( LED_NE ); delay_ms ( ROTATE_MS );
        output_low ( LED_NE ); output_high ( LED_E ); delay_ms ( ROTATE_MS );
        output_low ( LED_E ); output_high ( LED_SE ); delay_ms ( ROTATE_MS );
        output_low ( LED_SE ); output_high ( LED_S ); delay_ms ( ROTATE_MS );
        output_low ( LED_S ); output_high ( LED_SW ); delay_ms ( ROTATE_MS );
        output_low ( LED_SW ); output_high ( LED_W ); delay_ms ( ROTATE_MS );
        output_low ( LED_W ); output_high ( LED_NW ); delay_ms ( ROTATE_MS );
        }
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 10:08 am     Reply with quote

edhaslam,

The for loop is a piece of code before the main() just to see that the program had started. It doesn't do anymore.
I could start debugging the INT_RDA handler just to watch if something is arraiving. For example:
Code:

#int_rda
void SerialInterrupt ( void )
    {
    char cChar;

    if ( rs232_errors & 0x04 )  // get framing error bit from Rx status reg
        {
        cRxErrorFlag = ON;
        }

    cChar = getchar();       // get char from UART, clear any errors
   
    if(cChar == DOLLAR )  // if start of NMEA0183 message
      {
       output_high ( LED_n ); // Just to see if the first char of the GPS stream ('$') had arrived
      }
..................................




I can't help you anymore that in code because I didn't implement this code nor has
a GPS receiver to play with. May be somebody that had worked with this can help you.

Keep well,

Humberto
edhaslam



Joined: 15 Jul 2005
Posts: 89
Location: UK

View user's profile Send private message

PostPosted: Mon Jan 16, 2006 1:42 pm     Reply with quote

Humberto wrote:
edhaslam,

The for loop is a piece of code before the main() just to see that the program had started. It doesn't do anymore.
I could start debugging the INT_RDA handler just to watch if something is arraiving. For example:
Code:

#int_rda
void SerialInterrupt ( void )
    {
    char cChar;

    if ( rs232_errors & 0x04 )  // get framing error bit from Rx status reg
        {
        cRxErrorFlag = ON;
        }

    cChar = getchar();       // get char from UART, clear any errors
   
    if(cChar == DOLLAR )  // if start of NMEA0183 message
      {
       output_high ( LED_n ); // Just to see if the first char of the GPS stream ('$') had arrived
      }
..................................




I can't help you anymore that in code because I didn't implement this code nor has
a GPS receiver to play with. May be somebody that had worked with this can help you.

Keep well,

Humberto


Hi Humberto,

Many thanks - I'll try the RDA debugging code you suggested. I understand that it's hard to debug without seeing the hardware.

Many thanks again,
Ed
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