I'm using a PIC 16F887 and I'd like to use the internal oscillator HFINTOSC. To accomplish this, I set the IRCF 2:0 bits to 110 (4Mhz prescaler) and the FOSC 2:0 config bits to INTOSC.
Now I should do something I really can't understand: according to the datasheet (see pag. 61) I should set the bit SCS in order to use the internal clock source (see the final MUX on the diagram on pag. 61). Because the SCS bit is in the OSCON register I should set it programmatically on my code but the code itself needs a clock source to be executed! How can I execute a code to set a bit to use a clock if the code needs a clock source in the first place?????
I quote the datasheet for the SCS bit:
4.6.1 SYSTEM CLOCK SELECT (SCS) BIT The System Clock Select (SCS) bit of the OSCCON register selects the system clock source that is used for the CPU and peripherals. • WhentheSCSbitoftheOSCCONregister=0, the system clock source is determined by configuration of the FOSC<2:0> bits in the Configuration Word Register 1 (CONFIG1). • WhentheSCSbitoftheOSCCONregister=1, the system clock source is chosen by the internal oscillator frequency selected by the IRCF<2:0> bits of the OSCCON register. After a Reset, the SCS bit of the OSCCON register is always cleared.