1
\$\begingroup\$

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:-

#include<PIC18f4550.h>
#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?

asked Mar 14, 2015 at 6:52
\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

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

answered Mar 14, 2015 at 7:58
\$\endgroup\$
1
  • \$\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\$ Commented Mar 14, 2015 at 9:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.