#2242 pic16f458 'Undefined identifier' GIE

open
None
PIC16
5
2014-11-15
2014-01-18
No

Hi,

I am trying to compile code for the pic18f458, but the compiler complains complaining it cannot find identifiers, e.g. GIE

SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jan 17 2014) (Linux)

Code below, commands line is 'sdcc --use-non-free -mpic16 -p18f458 -c test458.c'

include <pic18f458.h>

void main(void)
{
TRISB = 0x00;
PORTB = 0xFF;

GIE = 0x1;

while(1)
{ 
}

}

Error message 'test458.c:8: error 20: Undefined identifier 'GIE'.

Note, the same code (except header) will compile OK for a pic16f819 target code below - command line 'sdcc --use-non-free -mpic14 -p16f819 -c test819.c'

include <pic16f819.h>

void main(void)
{
TRISB = 0x00;
PORTB = 0xFF;

GIE = 0x1;

while(1)
{ 
}

}

Discussion

  • David Cary

    David Cary - 2014-01-23

    Many registers on the PIC18F have a slightly different name than the more-or-less equivalent register on the PIC16F.

    Any programmer who ports code from a PIC16F chip to a PIC18F chip will need to change PIC16F register names to the corresponding PIC18F register names. In this case, "GIE" needs to be changed to "GIEH".
    Also, you may need to set other registers on the PIC18F -- such as "GIEL" -- that have no corresponding register on the PIC16F.

    SDCC gives an "Undefined identifier 'GIE'." when compiling for the PIC18F, just as it should for any code that uses a register that does not exist in that chip. It's irrelevant whether that register does exist on some other chip or not.

    Details:

     
  • Molnár Károly

    Molnár Károly - 2014-02-02

    The GIE and GIEH not register names. These names of a bit, which is located in the INTCON register. The exact name: INTCONbits.GIE
    For compatibility, at the end of each PIC16F header there is a section that defines the bits. It is therefore possible to achieve INTCONbits.GIE bit alias than GIE also. These definitions case for PIC18F is not available. Therefore out there shall be so designated: INTCONbits.GIE

     
  • Molnár Károly

    Molnár Károly - 2014-02-04
    • assigned_to: Molnár Károly
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks