Author Topic: Config word reading on PIC  (Read 1315 times)

0 Members and 1 Guest are viewing this topic.

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Config word reading on PIC
« 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)
You can release yourself but the only way to go is down!
RJD
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14538
  • Country: fr
Re: Config word reading on PIC
« Reply #1 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.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3148
  • Country: ca
Re: Config word reading on PIC
« Reply #2 on: November 14, 2021, 05:30:40 pm »
Read the "NVMREG Access" chapter in the datasheet.
 
The following users thanked this post: PerranOak

Offline PerranOakTopic starter

  • Frequent Contributor
  • **
  • Posts: 548
  • Country: gb
Re: Config word reading on PIC
« Reply #3 on: November 17, 2021, 02:08:11 pm »
Brilliant, cheers.

I'd never noticed NVMREG but it worked a treat, thanks.
You can release yourself but the only way to go is down!
RJD
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf