I am new to PIC Programming, and thought of blinking LEDs as my first project. Now I copied a code from net which blinks two LEDs and its working, the LEDs are blinking.

My settings:-

I haven't connected any external oscillator to the PIC18f4550 and I am simulating the project using Proteus 8.1, In the Edit Components of PIC, Processor Clock Frequency is at 4MHz. But when I stop the simulation, I get the following message,"clocking 4Mhz specified in the component is ignored for oscillator mode INT-RC , NO CLKO". And note, I haven't used OSCCON register in my code.

My code:-


#pragma config PLLDIV = 5 , CPUDIV = OSC1_PLL2 , USBDIV = 2    
#pragma config FOSC = INTOSCIO_EC
#pragma config FCMEN = OFF                                
#pragma config BORV = 3
#pragma config WDT = OFF
#pragma config CPB = OFF
#pragma config CPD = OFF
void main(void)
//blinking code here
//OSCCON register is not set.

My question:-

I am curious, if there is no external oscillator, internal oscillator register is not set and the Proteus is ignoring the schematic 4Mhz as clock frequency, then at what frequency is the microcontroller operating?


Every register in the microcontroller exists whether you explicitly set a value or not. If you don't explicitly change the value of a register, the microcontroller will happily use the default value. The default values for each and every bit are defined in the datasheet.

For Microchip products, the default bit values for each register are defined along the top of the register description. See the red circled-area in the screen capture below. The OSCCON register defaults to a value of \$0100?000_2\$. The ? represents a read-only bit that has no default value upon power up. Looking at just the Internal Oscillator Frequency Select bits, IRCF, the default bits are \$100_2\$. So your default frequency is 1MHz.

enter image description here

  • \$\begingroup\$ +1. And you don't even have to look at the default bit values in registers; I'm pretty sure the default Internal Oscillator Frequency is specified somewhere in the datasheet. \$\endgroup\$ – m.Alin Mar 14 '15 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.