First off, you should use CON to define a numeric constant instead of DEFINE
Next, since the intosc defaults to 500KHz at startup, that's outside the range of the 4xPLL which is spec'd from 4MHz-8MHz.
While it might work, I'd leave the CONFIG setting for the PLL off and enable it when you change the osc freq
Something like this should work:
Code:#CONFIG __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __CONFIG _CONFIG2, _WRT_OFF & _VCAPEN_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_OFF #ENDCONFIG DEFINE OSC 32 ' OSCCON register settings SPLLEN CON %1 ' PLL enable IRCF CON %1110 ' to enable 8 MHz SCS CON %00 ' system clock determined by FOSC OSCCON = (SPLLEN<<7) | (IRCF<<3) | SCS




Bookmarks