Estoy intentando cambiar de un reloj externo de 8MHz al reloj interno de 31kHz en el PIC18F4550.
este es mi código
#include <p18cxxx.h>
#include <delays.h>
#pragma config PLLDIV = 2, CPUDIV = OSC1_PLL2, USBDIV = 2,FOSC = HSPLL_HS, FCMEN = OFF,
IESO = ON, PWRT = OFF, BOR = OFF, VREGEN = OFF, WDT = OFF, CCP2MX = ON, PBADEN = OFF,
LPT1OSC = OFF, MCLRE = ON, STVREN = OFF, LVP = OFF, ICPRT = OFF, XINST = ON, DEBUG = OFF,
CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF, CPB = OFF, CPD = OFF, WRT0 = OFF, WRT1 = OFF,
WRT2 = OFF, WRT3 = OFF, WRTC = OFF, WRTB = OFF, WRTD = OFF, EBTR0 = OFF, EBTR1 = OFF,
EBTR2 = OFF, EBTR3 = OFF, EBTRB = OFF
int main(void) {
long int i = 0;
PORTB = 0;
TRISB = 0;
PORTB = 0;
OSCTUNE = 0;//use internal INTRC osciallator for 32kHz clock
while (1){
while (i++ <100000){
PORTBbits.RB1 = ~PORTBbits.RB1;//toggle RB1 in external clock mode
}
i=0;//reset counter i
OSCCON = 2;//switch clock to 32khz clock
PORTBbits.RB5 = 1;//set RB5 high while in 32kHz mode
while (i++<500){
PORTBbits.RB1 = ~PORTBbits.RB1;//toggle RB1
}
OSCCON = 0;//set clock back to exterl oscillator
i = 0;//reset counter
PORTBbits.RB5 = 0;//clear RB5 while in external oscillator mode
}
return 0;
}
conecté PORTB a un alcance para ver si la forma de onda cambiaría pero no lo hizo, lo que me hace creer que no se produjo ningún cambio de reloj. No estoy seguro de dónde lo entiendo mal.
Estoy usando MPLABX con compilador C18.
EDITADO: