EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: PerranOak on November 14, 2021, 05:10:35 pm
-
I wanted to display (just with some LEDs for a quick check) the actual value of some config word data in my PIC.
I, naively, thought I could just attach LEDs to the relevant pins and run this:
PORTAbits.RA0 = FEXTOSC0;
PORTAbits.RA1 = FEXTOSC1;
PORTAbits.RA2 = FEXTOSC2;
However, I get: error: use of undeclared identifier 'FEXTOSC0'
Can config words be read directly like this? If not, how can I read them from the chip without going via MPLAB, etc.?
Thank you.
(using a PIC16F15376)
-
The configuration words are stored in registers in the PIC16F and should be available as CONFIG1L, CONFIG1H, CONFIG2L, etc. See datasheet for how each codes which configuration bits.
I don't know if those registers are defined in the header files (haven't used PIC16F MCUs in ages) and can directly be read from C. Check that out.
In any case, you'll be reading the config data in a number of registers.
-
Read the "NVMREG Access" chapter in the datasheet.
-
Brilliant, cheers.
I'd never noticed NVMREG but it worked a treat, thanks.