Hello
I have doubts, about whether it is really necessary, to put two capacitors using a 16Mhz crystal with the NXP Kinetis MK66 microcontroller at 180Mhz.
I think I read somewhere, that capacitors are only necessary when using crystals of up to 8Mhz. For example in the Teensy 3.6 that uses a Kinetis MK66, according to the scheme there are no capacitors with the 16Mhz crystal, on the other hand I have designs with STM32 with 8Mhz crystal and it does not start if I do not put the capacitors.
So, the question is when it is necessary to put capacitors with the microcontroller's oscillator crystal.
My current schematic with MK66 (LQFP 144 pin)
Teensy 3.6 Schematic with MK66 (BGA)
Luis
In the uTasker project (files you reference) the gain mode is controlled in app_hw_kinetis.h.
For example, when the FRDM-K66F is used it selects #define OSC_LOW_GAIN_MODE
Other boards don't select this, which then defaults to high gain mode.
The actual control is performed as follows in kinetis.c
MCG_C2 = (MCG_C2_RANGE_8M_32M | MCG_C2_GAIN_MODE | MCG_C2_EREFS | MCG_C2_LOCRE0); // select crystal oscillator and select a suitable range
whereby
#if defined OSC_LOW_GAIN_MODE // if using low frequency low power mode no external resistor or load capacitors are used
#define MCG_C2_GAIN_MODE 0 // don't select high gain mode since the oscillator will not start
#else
#define MCG_C2_GAIN_MODE MCG_C2_HGO // select high gain mode
#endif
Regards
Mark
OK, thanks Mark.
I use FRDM_K66F and TEENSY_3_5, both with OSC_LOW_GAIN_MODE, so perfect for me to remove the capacitors.
Hi
Designs tend to not use any loading capacitors (eg. FRDM-K66F with 12MHz crystal or, as you point out, the teensy3.6 with 16MHz crystal).
Like this the low gain mode needs to be programmed in MCG_C2.
If loading capacitors (and feedback resistance) are used the high gain mode (HGO bit) must be set.
That means that with and without are OK but the programming has to match. In both cases with wrong setting of HGO the oscillator will tend not to start...
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Hello Mark.
I know that in Teensy 3.6, the sources work by default with external capacitors.
But where can I configure or modify in uTasker Bootloader ?.
I have found the following sources where MCG_C2 is, but I do not know where to modify it.
kinetis.c
kinetis.h
kinetis_boot.c
kinetis_FLEXTIMER.h
kinetis_LPTMR.h
kinetis_PWM.h
kinetis_UART.h
kinetis_USB_Device.h
kinetis_USB_HS_Device.h
kinetis_USB_OTG.h
kinetisSim.c
I suspect that it is defined in kinetis_boot.c in these lines of source code, but I'm not sure:
#ifdef EXTERNAL_CLOCK // first move from state FEI to state FBE (presently running from about 25MHz internal clock)
MCG_C2 = (MCG_C2_RANGE_8M_32M); // don't use oscillator
MCG_C1 = (MCG_C1_CLKS_EXTERN_CLK | MCG_C1_FRDIV_1024); // switch to external input clock (the FLL input clock is set to as close to its input range as possible, although this is not necessary since the FLL will not be used)
#else
#if CRYSTAL_FREQUENCY > 8000000
MCG_C2 = (MCG_C2_RANGE_8M_32M | MCG_C2_HGO | MCG_C2_EREFS); // select crystal oscillator
#elif CRYSTAL_FREQUENCY >= 1000000
MCG_C2 = (MCG_C2_RANGE_1M_8M | MCG_C2_HGO | MCG_C2_EREFS); // select crystal oscillator
#else // assumed to be 32kHz crystal
MCG_C2 = (MCG_C2_RANGE_32K_40K | MCG_C2_HGO | MCG_C2_EREFS); // select crystal oscillator
#endif
MCG_C1 = (MCG_C1_CLKS_EXTERN_CLK | MCG_C1_FRDIV_256); // switch to external source (the FLL input clock is set to as close to its input range as possible, although this is not absolutely necessary since the FLL will not be used) this is accurate for 8MHz clock but hasn't been tested for other values
while (!(MCG_S & MCG_S_OSCINIT)) { // loop until the crystal source has been selected
#ifdef _WINDOWS
MCG_S |= MCG_S_OSCINIT;
#endif
}
#endif
I see in old Processor Expert software, there is option to choose between High gain and Low power for Oscillator Operating Mode, I understand this is the parameter to allow internal capacitors. I want to check where is available in MCUxpresso and KDS.
Ok, thanks Mark.
I did not know about MCG_C2 and the HGO bit, I'll check it, I guess it's in the MK66 Reference Manual.
Or where do you suggest I can find more detailed information on how to set it up?