I'm trying to set the weak internal pull-up resistor for a GPIO, but can't seem to guess the right macro name that maps to whatever memory address in the PIC.
None of these seem to be recognized by the compiler. What is the proper way to look these up? All I include is <xc.h>
so I have no idea where the actual header file is.
I have the datasheet with the register definition open for WPUB, but it does not map to code in any consistent way that I can find:
#include <xc.h>
void InitGpio(void) {
TRISBbits.TRISB3 = 1; // compiler recognizes
WPUBbits.WPUB3 = 1; // 'undefined identifier' compiler error
WPUB.WPUB3 = 1; // 'undefined identifier' compiler error
WPUB = 1; // 'undefined identifier' compiler error
WPUB3 = 1; // 'undefined identifier' compiler error
_WPUB = 1; // 'undefined identifier' compiler error
_WPUB3 = 1; // 'undefined identifier' compiler error
}
Best Answer
Every PIC microcontroller has it's own specific header file which contains its register definitions. Look in the compiler's
include
directory for your own PIC. Theinclude
directory on my machine is located here:c:\Program Files (x86)\Microchip\xc8\v1.31\include\
Here's the definitions related to the Weak Pull-up Registers for a random PIC (PIC16LF722):