How to read configuration bit register from PIC

cmicrocontrollermplabxpic

I'm debugging and want to inspect

CONFIG1H (CONFIGURATION REGISTER 1 HIGH)

of a PIC18F. CONFIG1H does seem to be recongized as an SFR when I enter it into the Watch window.

After stopping at a breakpoint, you can open the configuration bits window:

Window >> PIC Memory Views >> Configuration bits

but it's unclear whether those are cached in MPLABX or newly read from the MCU.

Best Answer

To avoid this ambiguity, you should embed the CONFIG register settings in your source code. Then, when you compile your code, it embeds the settings into your hex file.

As you stated, you can view the Configuration Bits. This is not to set them, however, as much as to assist you in formatting them for your code. Once you select what you want, click where it says "Generate Source Code":

config

It will give you formatted #pragma statements that you can copy directly into your source files:

code

Put these statements in the source code, outside of any function. I put mine at the top of my main.c file.

Good luck!