Merge pull request #303 from stapelberg/hsrun

MK66F18: only enter HSRUN mode if actually necessary (> 120 MHz)
This commit is contained in:
Fabien Poussin 2022-02-06 22:13:10 +01:00 committed by GitHub
commit d1a7bf2e8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -228,13 +228,13 @@ void MK66F18_clock_init(void) {
#define MCG_C6_VDIV0 MCG_C6_VDIV0_SET
#if 1 /* PJRC_HSRUN */
// 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
#define SMC_PMSTAT_HSRUN ((uint8_t)0x80)
while (SMC->PMSTAT != SMC_PMSTAT_HSRUN)
; // wait for HSRUN
#if F_CPU == 256000000
#endif
#if F_CPU == 256000000
//See table in 27.4.6 MCG Control 6 Register (MCG_C6)
//16 -> Multiply factor 32. 32*8MHz =256MHz
MCG_C5 = MCG_C5_PRDIV0(0);