Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
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?
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."