Internal oscillator for PIC18F4550
I am trying to use the internal oscillator as the CPU clock. According to the datasheet, the internal oscillator is accessed through the CONFIG1H register, and the OSSCON register. This is the code:
#pragma config WDT = OFF
#pragma config FOSC = INTOSC_EC // internal oscillator, RA6 = clock out
#pragma config MCLRE = OFF // MCLR is disabled
OSCCON = 0xF2; // internal oscillator, 8MHz
TRISD = 0;
When FOSC = INTOSC_EC, the actual value for FOSC<3:0> = b'1001', which accesses the internal clock and sets RA6 as a Fosc/4 pin.
When OSSCON = b'11110010', the internal clock is driven at 8MHz, with SCS<1:0> = b'10', which activates the internal oscillator.
According to this little program, the output to RA6 should be a square wave driven at Fosc/4, which is 2 MHz.
The actual output that I see on my oscilloscope is a 2 MHz waveform that turns on and off every 8 miliseconds. For 8ms I get a perfectly nice clock signal, but then it shuts off for the next 8ms, and the process repeats again. I was thinking that perhaps the power supply was erratic, but this is not the case. I have an even 5V power supply. Also, I have connected 1uF capacitors across Vdd and Vss pins to prevent any voltage spikes from forming.
The watchdog timer is disabled, so there should be no reason why the clock stops every 8ms. Is there any other reason why the internal clock behaves like this?