@@ -33,6 +33,18 @@ extern "C"
33
33
* @name Clock system configuration
34
34
* @{
35
35
*/
36
+ /* The crystal on the Mulle is designed for 12.5 pF load capacitance. According
37
+ * to the data sheet, the K60 will have a 5 pF parasitic capacitance on the
38
+ * XTAL32/EXTAL32 connection. The board traces might give some minor parasitic
39
+ * capacitance as well. */
40
+ /* Use the equation
41
+ * CL = (C1 * C2) / (C1 + C2) + Cstray
42
+ * with C1 == C2:
43
+ * C1 = 2 * (CL - Cstray)
44
+ */
45
+ /* enable 14pF load capacitor which will yield a crystal load capacitance of 12 pF */
46
+ #define RTC_LOAD_CAP_BITS (RTC_CR_SC8P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC2P_MASK)
47
+
36
48
static const clock_config_t clock_config = {
37
49
/*
38
50
* This configuration results in the system running from the FLL output with
@@ -48,24 +60,28 @@ static const clock_config_t clock_config = {
48
60
* consumption than using the 16 MHz crystal and the OSC0 module */
49
61
.clkdiv1 = SIM_CLKDIV1_OUTDIV1 (0 ) | SIM_CLKDIV1_OUTDIV2 (0 ) |
50
62
SIM_CLKDIV1_OUTDIV3 (1 ) | SIM_CLKDIV1_OUTDIV4 (1 ),
63
+ .rtc_clc = RTC_LOAD_CAP_BITS ,
64
+ .osc32ksel = SIM_SOPT1_OSC32KSEL (2 ),
65
+ .clock_flags =
66
+ /* no OSC0_EN, the RTC module provides the clock input signal for the FLL */
67
+ KINETIS_CLOCK_RTCOSC_EN |
68
+ KINETIS_CLOCK_USE_FAST_IRC |
69
+ 0 ,
51
70
.default_mode = KINETIS_MCG_MODE_FEE ,
52
71
.erc_range = KINETIS_MCG_ERC_RANGE_LOW , /* Input clock is 32768 Hz */
53
- .fcrdiv = 0 , /* Fast IRC divide by 1 => 4 MHz */
54
- .oscsel = 1 , /* Use RTC for external clock */
55
72
/* 16 pF capacitors yield ca 10 pF load capacitance as required by the
56
73
* onboard xtal, not used when OSC0 is disabled */
57
- .clc = 0b0001 ,
58
- .fll_frdiv = 0b000 , /* Divide by 1 => FLL input 32768 Hz */
74
+ .osc_clc = OSC_CR_SC16P_MASK ,
75
+ .oscsel = MCG_C7_OSCSEL (1 ), /* Use RTC for external clock */
76
+ .fcrdiv = MCG_SC_FCRDIV (0 ), /* Fast IRC divide by 1 => 4 MHz */
77
+ .fll_frdiv = MCG_C1_FRDIV (0b000 ), /* Divide by 1 => FLL input 32768 Hz */
59
78
.fll_factor_fei = KINETIS_MCG_FLL_FACTOR_1464 , /* FLL freq = 48 MHz */
60
79
.fll_factor_fee = KINETIS_MCG_FLL_FACTOR_1464 , /* FLL freq = 48 MHz */
61
80
/* PLL is unavailable when using a 32768 Hz source clock, so the
62
81
* configuration below can only be used if the above config is modified to
63
82
* use the 16 MHz crystal instead of the RTC. */
64
- .pll_prdiv = 0b00111 , /* Divide by 8 */
65
- .pll_vdiv = 0b01100 , /* Multiply by 36 => PLL freq = 72 MHz */
66
- .enable_oscillator = false, /* the RTC module provides the clock input signal */
67
- .select_fast_irc = true, /* Only used for FBI mode */
68
- .enable_mcgirclk = false,
83
+ .pll_prdiv = MCG_C5_PRDIV0 (0b00111 ), /* Divide by 8 */
84
+ .pll_vdiv = MCG_C6_VDIV0 (0b01100 ), /* Multiply by 36 => PLL freq = 72 MHz */
69
85
};
70
86
#define CLOCK_CORECLOCK (48000000ul)
71
87
#define CLOCK_BUSCLOCK (CLOCK_CORECLOCK / 1)
@@ -382,21 +398,6 @@ static const spi_conf_t spi_config[] = {
382
398
#define RTT_MAX_VALUE (0xffffffff)
383
399
#define RTT_FREQUENCY (1) /* in Hz */
384
400
385
- /**
386
- * RTC module crystal load capacitance configuration bits.
387
- */
388
- /* The crystal on the Mulle is designed for 12.5 pF load capacitance. According
389
- * to the data sheet, the K60 will have a 5 pF parasitic capacitance on the
390
- * XTAL32/EXTAL32 connection. The board traces might give some minor parasitic
391
- * capacitance as well. */
392
- /* Use the equation
393
- * CL = (C1 * C2) / (C1 + C2) + Cstray
394
- * with C1 == C2:
395
- * C1 = 2 * (CL - Cstray)
396
- */
397
- /* enable 14pF load capacitor which will yield a crystal load capacitance of 12 pF */
398
- #define RTC_LOAD_CAP_BITS (RTC_CR_SC8P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC2P_MASK)
399
-
400
401
/** @} */
401
402
402
403
#ifdef __cplusplus
0 commit comments