Other Parts Discussed in Thread: CONTROLSUITE
Hello,
For my application I want to switch after boot to an external oscillator. This oscillator is connected to X1/X2 pins. In the bootloader I use the internal oscillator, after the App starts i switch to the external oscillator.
the problem is that the CPU seems to keep resetting. I suspect the VCOCLK getting an overflow since it doesn't get cleared by OSCCLK. However im not sure.
What is interesting is by running the app in debug mode (i.e no bootloader), the app works OK, and no reset happens. this means that the oscillator settings in the App are not faulty. The Oscillator settings in the bootloader are not faulty either, since if i undo the oscillator changes in the App everything still works, carrying on with the oscillator settings in the bootloader.
Somehow the transition between internal/external oscillator doesnt go smoothly.
below are the bootloader Oscillator steps:
// enable internal oscillator 1 CLK_enableOsc1(obj->clkHandle); // disable the external clock in CLK_disableClkIn(obj->clkHandle); // disable the crystal oscillator CLK_disableCrystalOsc(obj->clkHandle); // disable oscillator 2 CLK_disableOsc2(obj->clkHandle); // set the oscillator source CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_Internal); // set the low speed clock prescaler CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4); // set the clock out prescaler CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);
the steps for switching (that happen in the App):
// disable the external clock in. check ref. doc page 12. X1 CLK_disableClkIn(obj->clkHandle); CLK_setOsc2Src(obj->clkHandle,CLK_Osc2Src_Internal); // set the oscillator source CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_External); // moved to last CLK_disableOsc1(obj->clkHandle); // todo check // set the low speed clock prescaler CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4); // set the clock out prescaler CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);
it seems that somehow the transition between the 2 clocks is problematic. Did anyone have a similar experience?
Thanks,