Hi,
My code was working with 12MHz IRC_OSC and looking for accuracy I've decided to use a XTAL, so I'm trying to configure an external 8MHz cristal oscilator. To do that, I've used mcuxpresso's clock configurator and code generator.
I'm not able to run code with 8MHz SYS-OSC input. Code continues running at 12MHz with IRC. If I disable IRC_Osc, code is not executed.
This is my code of clock configuration:
void BOARD_BootClockRUN(void)
{
/*!< Set up the clock sources */
/*!< Set up IRC */
POWER_DisablePD(kPDRUNCFG_PD_IRC_OUT); /*!< Ensure IRC OUT is on */
POWER_DisablePD(kPDRUNCFG_PD_IRC); /*!< Ensure IRC is on */
POWER_DisablePD(kPDRUNCFG_PD_SYSOSC); /*!< Ensure SYSOSC is on */
CLOCK_InitSysOsc(8000000U); /*!< Set main osc freq */
CLOCK_Select(kSYSPLL_From_SysOsc); /*!< set sysosc to pll select */
CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcSysPllin); /*!< select pllin for main clock */
CLOCK_Select(kCLKOUT_From_MainClk); /*!< select main osc or mclkin for CLKOUT */
CLOCK_SetCoreSysClkDiv(1U);
CLOCK_SetClkDivider(kCLOCK_DivClkOut, 1U); /*!< set CLOCKOUT div */
CLOCK_UpdateClkOUTsrc(); /*!< updates the clock source of the CLKOUT pin */
CLOCK_SetClkDivider(kCLOCK_DivUsartClk, 1U); /*!< set UART div */
SYSCON->UARTFRGDIV = 0; /*!> Set UARTFRGDIV */
CLOCK_SetUARTFRGMULT(0U); /*!< Set UARTFRGMULT */
POWER_EnablePD(kPDRUNCFG_PD_IRC_OUT); /*!< Disable IRC OUT */
POWER_EnablePD(kPDRUNCFG_PD_IRC); /*!< Disable IRC */
/*!< Set SystemCoreClock variable. */
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
}
Any helping with that ?
Thanks in advance,
Asier.
Hello Alexis,
Yes, I've set pins PIO0_8 and the PIO0_9 to the XTALIN/XTALOUT function and I've verified that next code lines appears in pin_mux.c file:
/* XTALIN connect to P0_8 */
SWM_SetFixedPinSelect(SWM0, kSWM_XTALIN, true);
/* XTALOUT connect to P0_9 */
SWM_SetFixedPinSelect(SWM0, kSWM_XTALOUT, true);
Pins are correct and system oscillator module is working because I can see 8MHz signal in CLKOUT pin when I select "clk_in" in CLKOUTSEL.
It seems that the problem is in the Main Clock Selector. I select "PLL input" signal with "CLOCK_SetMainClkSrc(kCLOCK_MainClkSrcSysPllin);" but no clock appears at "Main clock".
Is necesary that PLL module was enabled for catching the "PLL input" signal ?
Thank you very much,
Asier
I've tried with next:
SYSCON->MAINCLKSEL = 0x01; // Main clock source select: PLL input
SYSCON->MAINCLKUEN = 0x01; // Updtate new MAINCLKSEL clock source
but no way.
I'm stuck. Anybody there for helping ?
Thanks,
Asier.
I forgot to mention that Im asigning CLKOUT to PIO0_4 pin. When selecting "clk_in" on CLKOUTSEL, I can see 8MHz in the output pin, but selecting "main_clk" option no signal appear.
In the other hand, if I leave IRC_osc enabled and we select "main_clk" option in CLKOUTSEL, IRC_osc 12MHz signal appears in CLKOUT.
It seems like if MAINCLKSEL is not changing to "PLL input" mode but it stays at "IRC_clk" mode.
Any idea what I'm doing wrong ?
Thanks,
Asier.