Search code examples
cembeddedmplabpic32

Can't declare output in MPLAB X even though I included the header file


I am trying to program a PIC32MX470F512H to execute a simple LED blinking program; however, I am recieving errors when declaring the LED output. I am not exactly sure the reason behind the error, and documentation on it is scarce.

enter image description here

I have looked into cases with similar errors; however, in those, they are still able to successfully compile the code, but I am not.


Solution

  • The compiler switch -mprocessor=32MX470F512L causes __32MX470F512L__ to be defined, which is used in xc.h to conditionally include proc/p32mx470f512l.h where TRISE4 and RE4 are defined.

    However looking at the definition, it is clear that they are defined as members of TRISEbits and PORTEbits respectively. So:

    TRISEbits.TRISE4 = 0 ;
    

    and

    #define LED (PORTEbits.RE4)