EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: PerranOak on November 14, 2021, 05:10:35 pm

Title: Config word reading on PIC
Post 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:

Code: [Select]
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)
Title: Re: Config word reading on PIC
Post by: SiliconWizard on November 14, 2021, 05:18:52 pm
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.
Title: Re: Config word reading on PIC
Post by: NorthGuy on November 14, 2021, 05:30:40 pm
Read the "NVMREG Access" chapter in the datasheet.
Title: Re: Config word reading on PIC
Post by: PerranOak on November 17, 2021, 02:08:11 pm
Brilliant, cheers.

I'd never noticed NVMREG but it worked a treat, thanks.