Electronic – Use PIC internal oscillator

oscillatorpic

I'm using a PIC16F1824 with an external 4MHz oscillator. I actually want to use the internal oscillator, but the timing seems incorrect.

For example, I tried to use delay_ms(1000), and it delayed 5 seconds instead of the expected 1 second.

What did I do wrong?

Data sheet:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en546901

I'm clueless reading the OSCCON details:
enter image description here

Best Answer

To get 4 MHz you set bit 6-3 of OSCCON to 1101 (page 71 of the data sheet).

I suggested that in a comment, and it apparently solved the problem.

The internal oscillator should be running when the device is reset, so you merely have to change those bits and you should be running from it at 4 MHz, instead of the 4 MHz crystal.