AnsweredAssumed Answered

MQX 4.2 K24 clock settings

Question asked by Ryan Lush on Jun 5, 2018
Latest reply on Jun 8, 2018 by Ryan Lush

I've noticed my clock is running slower than it should be. Inside of bsp_cm.c you have the following defines

 

/* Clock configuration 0 */
#define CPU_MCG_MODE_CONFIG_0                              (CPU_MCG_MODE_PEE | CPU_CLOCK_EXTERNAL_CRYSTAL_MASK | CPU_CLOCK_FAST_MASK) /* Clock generator mode */
#define CPU_CLOCK_VLP_CONFIG_0                             0U /* RUN power mode */

 

#define CPU_MCG_C1_CONFIG_0                                0x20U /* MCG_C1 */
#define CPU_MCG_C2_CONFIG_0                                0x25U /* MCG_C2 */
#define CPU_MCG_C4_CONFIG_0                                0x00U /* MCG_C4 */
#define CPU_MCG_C5_CONFIG_0                                0x03U /* MCG_C5 */
#define CPU_MCG_C6_CONFIG_0                                0x40U /* MCG_C6 */
#define CPU_MCG_SC_CONFIG_0                                0x02U /* MCG_SC */
#define CPU_OSC_CR_CONFIG_0                                0x80U /* OSC_CR */
#define CPU_SIM_SOPT1_CONFIG_0                             0x00080000UL /* SIM_SOPT1 */
#define CPU_SIM_SOPT2_CONFIG_0                             0x00010000UL /* SIM_SOPT2 */
#define CPU_SIM_CLKDIV1_CONFIG_0                           0x01130000UL /* SIM_CLKDIV1 */
/* Clock configuration 1 */
#define CPU_MCG_MODE_CONFIG_1                              (CPU_MCG_MODE_PEE | CPU_CLOCK_EXTERNAL_CRYSTAL_MASK | CPU_CLOCK_FAST_MASK) /* Clock generator mode */
#define CPU_CLOCK_VLP_CONFIG_1                             0U /* RUN power mode */

 

I've hand cranked these values for a 120MHz clock with a 16MHz crystal and they don't match the values above. Anyone know what these values should be given my scenario?

Outcomes