MK66F18: only enter HSRUN mode if actually necessary (> 120 MHz)
This more closely matches the Teensy arduino startup and EEPROM code.
This commit is contained in:
parent
1127b5575e
commit
c3c55769f8
|
@ -228,13 +228,13 @@ void MK66F18_clock_init(void) {
|
||||||
#define MCG_C6_VDIV0 MCG_C6_VDIV0_SET
|
#define MCG_C6_VDIV0 MCG_C6_VDIV0_SET
|
||||||
#if 1 /* PJRC_HSRUN */
|
#if 1 /* PJRC_HSRUN */
|
||||||
// if we need faster than the crystal, turn on the PLL
|
// if we need faster than the crystal, turn on the PLL
|
||||||
|
#if F_CPU > 120000000
|
||||||
SMC->PMCTRL = SMC_PMCTRL_RUNM_SET(3); // enter HSRUN mode
|
SMC->PMCTRL = SMC_PMCTRL_RUNM_SET(3); // enter HSRUN mode
|
||||||
#define SMC_PMSTAT_HSRUN ((uint8_t)0x80)
|
#define SMC_PMSTAT_HSRUN ((uint8_t)0x80)
|
||||||
while (SMC->PMSTAT != SMC_PMSTAT_HSRUN)
|
while (SMC->PMSTAT != SMC_PMSTAT_HSRUN)
|
||||||
; // wait for HSRUN
|
; // wait for HSRUN
|
||||||
|
#endif
|
||||||
#if F_CPU == 256000000
|
#if F_CPU == 256000000
|
||||||
//See table in 27.4.6 MCG Control 6 Register (MCG_C6)
|
//See table in 27.4.6 MCG Control 6 Register (MCG_C6)
|
||||||
//16 -> Multiply factor 32. 32*8MHz =256MHz
|
//16 -> Multiply factor 32. 32*8MHz =256MHz
|
||||||
MCG_C5 = MCG_C5_PRDIV0(0);
|
MCG_C5 = MCG_C5_PRDIV0(0);
|
||||||
|
|
Loading…
Reference in New Issue