There is also an option to control the reset via software. The voltage can be specified by Brown out voltage configuration settings. #pragma config PWRT = OFF // Power up timer Disabled Brown out resetīrown out reset allows the microcontroller to reset when the supply voltage drops below a specific voltage. #pragma config PWRT = ON // Power up timer enabled These settings can be controlled by below options. The power-up timer introduces a small delay after power-up reset or brown-out reset. #pragma config CPUDIV = OSC4_PLL6 // Power up timer For example, it is useful to generate 48MHz from the PLL by using OSC1_PLL2 option. System clock postscaler is used for scaling the frequency before delivering to the clock. #pragma config PLLDIV = 12 // Divide by 12 (48MHz input) CPU System Clock Postscaler #pragma config PLLDIV = 10 // Divide by 10 (40MHz input) #pragma config PLLDIV = 6 // Divide by 6 (24MHz input) #pragma config PLLDIV = 5 // Divide by 5 (20MHz input) #pragma config PLLDIV = 4 // Divide by 4 (16MHz input) #pragma config PLLDIV = 3 // Divide by 3 (12MHz input) #pragma config PLLDIV = 2 // Divide by 2 (8MHz input) #pragma config PLLDIV = 1 // No divide (4MHz input) The PLL prescaler divides the clock to get the 4MHz input to the PLL. For using this option, first set the configuration bit for clock selection as HSPLL. The prescaler processes the clock before inputting to the PLL. PLL is used for generating a clock for USB. #pragma config USBDIV = 2 // Clock source from 96MHz PLL/2 96MHz PLL prescaler
#pragma config USBDIV = 1 // Clock source from OSC1/OSC2 Otherwise, we need to use PLL and postscaler to process the clock. If the clock is 6 MHz or 48 MHz, it can be used directly. USB accepts only 48MHz (full speed) and 6MHz (low speed) frequency clocks. This will select Full-Speed USB Clock Source, there are two choices. #pragma config IESO = OFF // Switch over Disabled, Put IESO = ON to enable USB clock selection Using this configuration bit, we can enable clock switcher between internal and external clocks. #pragma config FCMEM = ON // Failsafe enabled Internal/External switch over #pragma config FCMEM = OFF // Failsafe Disabled This option can be enabled by setting the FCMEM configuration bit. The fail-safe monitor allows the device to switch over to internal oscillators when external clock fails. Oscillator configuration bits – PIC18F4550 Fail-safe clock monitor Other 12 registers are used for setting configuration bits for PIC18F4550. The last two are device ID registers which are read-only. PIC18F4550 has 14 configuration registers, CONFIG1L, CONFIG1H, CONFIG2L, CONFIG2H, CONFIG3H, CONFIG4L, CONFIG5L, CONFIG5H, CONFIG6L, CONFIG6H, CONFIG7L, CONFIG7H, DEVID1, and DEVID2. Registers used for the setup of Configuration bits in PIC18F4550 The generated configuration bits can be used in the application by directly copying and pasting or saving it as a separate file and including it in the project. MPLAB X IDE has a configuration bits window to generate the directives based on the selected options. So it can only be accessed using table reads and table writes.Ĭonfiguration bits are directives written in the software.
These bits are mapped starting at program memory location 300000h.Ĭonfiguration bits are not accessible to the user through code because it belongs to the configuration memory space, not the user program memory space. They can be programmed to select various device configurations.
They can only be modified during programming time. Using these bits, we can essentially control where is the clock source, do the application needs watchdog timer etc. These are read during startup/reset and enable or disable different hardware features based on the values of bits. Configuration bits are special bits used for controlling different features in the Microcontroller.