I have 16MHz external crystal for K22.
I am using KSDK v2.1.
I've configured the clock to run in FEE:
void BootClockRUN_FEE(void)
{
const sim_clock_config_t simConfig = {
.pllFllSel = 0U, .er32kSrc = 3U, .clkdiv1 = 0x01340000U,
};
CLOCK_SetSimSafeDivs();
BOARD_InitOsc0();
CLOCK_BootToFeeMode(kMCG_OscselOsc, 4U, kMCG_Dmx32Default, kMCG_DrsMidHigh, BOARD_FllStableDelay);
CLOCK_SetInternalRefClkConfig(kMCG_IrclkEnable, kMCG_IrcSlow, 0U);
CLOCK_SetSimConfig(&simConfig);
SystemCoreClock = 80000000U;
}
After initializing the Clock management, I try to use PTC3 pin to scope the output of the flash clock to verify the SystemCoreClock is correct.
#define SIM_SCGC5_REG(base) ((base)->SCGC5)
#define SIM_SOPT2_REG(base) ((base)->SOPT2)
#define PORT_PCR_REG(base,index) ((base)->PCR[index])
#define SIM_SOPT2 SIM_SOPT2_REG(SIM)
#define SIM_SCGC5 SIM_SCGC5_REG(SIM)
#define PORTC_PCR3 PORT_PCR_REG(PORTC,3)
#define PORTC_PCR4 PORT_PCR_REG(PORTC,4)
SIM_SCGC5|=0x800;
PORTC_PCR3&=~(0x700);
PORTC_PCR3|=5<<8;
SIM_SOPT2|=2<<5;
I am expecting 16Mhz out for PTC3. Nothing is coming out.
Any ideas on where I went wrong?
Marek,
I just migrated to 2.0 and the new clock tool helped a great deal. I even used it to reevaluate older 1.3.0 projects.
Xiangjun,
Our package is the 64 pin LQFP.
Hi,
Can you tell me the package type of the K22? if you use 121 pins K22, the PTC3 is multiplexed with CLKOUT, of course your code is correct.
But if you use MK22DX128VLF5, MK22DX256VLF5, the PTC3 is not multiplexed with CLKOUT.
Pls have a check.
BR
Xiangjun Rong
Hi An Bui,
for KSDK 2.x there is Clocks tool available allowing to generate clock initialization for K22. The tool is provided both as a web version (on MCUXpresso web site) and also as desktop version (download installer on NXP.com), free of charge. The tool supports graphical configuration with validations and then generates complete clock initialization function (source code), that you can download or copy-paste into your application.
Regards
Marek