Maker Pro
Maker Pro

Oscillator Cofiguration microchip

I have seen the following sample code from microchip
Code:
_FOSCSEL(FNOSC_FRC);       
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF  & POSCMD_XT);   // Clock Switching is enabled and Fail Safe Clock Monitor is disabled
                                                   // OSC2 Pin Function: OSC2 is Clock Output
                                                   // Primary Oscillator Mode: XT Crystal
_FWDT(FWDTEN_OFF);           // Watchdog Timer Enabled/disabled by user software

I am bit confused about this.
The first instruction is
_FOSCSEL(FNOSC_FRC); which means from the header file Internal Fast RC (FRC).
the next instruction is
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_XT); the POSCMD_XT in the header file refers to XT Oscillator Mode. Why should i switch from internal FRC to external Oscillator mode, directly can i go to External oscillator mode? Can I avoid the first statement? Please suggest.
 
what is your micro and what framework you are using? I guess MPLAB.

Check your oscillator selection bit and Primary oscillator configuration.


This line look OK:
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_XT)

FCKSM = CSDCMD // Clock Switching and Monitor Selection
OSCIOFNC = OFF // CLKO Output Signal
POSCMOD = EC // Primary Oscillator Configuration (External Clock)
Check your datasheet for XT (is it external clock?)


you need check you Oscillator Selection Bits. Again your datasheet should say what bit you need to use it for external osc. For PIC32 it is FNOSC = SPLL.

Hope it helps.

--
Amar
 
Top