Microchip controllers confusion.

Status
Not open for further replies.
I am confused with the following configuration in microchip controllers where oscillator setting and watchdog setting are done above main. How is this possible without entering into main when this code is executed?
 
In C the compiler has a "pre process" compilation process... Everything above the main falls into this category...

The compiler will need to know function definitions all prama's and includes before the complilation of the main function..
 
This isn't actually code, it's configuration bits on the chip. It's simply a memory location that the compiler writes the configuration words to on the chip. When the PIC starts it checks these bit's internally and sets itself up before running any code. PIC compilers have special functions in order to tell the compiler and linker what goes in these bits when it programs the chip.

"The device configuration bits allow each user to customize certain aspects of the device to the needs of the application. When the device powers up, the state of these bits determines the modes that the device uses."
 
#pragma config is a compiler directive. Everything passed to this directive gets written to the configuration word memory space.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…