AnsweredAssumed Answered

Processor Expert - Clock Issue - MKE02Z16

Question asked by Daniel Hulshof on Feb 3, 2016
Latest reply on Mar 3, 2016 by Marek Neuzil

Hello there!

I'm using Kinetis Studio V3.1.0 and P.E. V3.0.2 developing software for the MKE02Z16 micro-controller.

Here are some issues I've encountered when fiddling with clock configurations using P.E.

I've attached images of the P.E. screen of each issue.

 

Issue 1:

On P.E. Component Inspector, editing "Cpu", setting "Slow internal reference clock" to 39.0625 and "ICS Mode" to FEI, the clock is not configured properly. The resulting clock should be 40Mhz (output prescaler set as 1), but in fact the clock generated (tested) was 32Mhz. That is because the generated code didn't change ICS_C3[SCTRIM] and ICS_C4[SCFTRIM] to the appropriate value. Actually, there was no apparent change to those registers. Here is the __init_hardware generated code:

 

void __init_hardware(void)

{

  /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/

  /*** ### MKE02Z16VLC4 "Cpu" init code ... ***/

  /*** PE initialization code after reset ***/

  SCB_VTOR = (uint32_t)(&__vect_table); /* Set the interrupt vector table position */

  /* Disable the WDOG module */

  /* WDOG_TOVAL: TOVAL=0xE803 */

  WDOG_TOVAL = WDOG_TOVAL_TOVAL(0xE803); /* Timeout value */

  /* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=1 */

  WDOG_CS2 = WDOG_CS2_CLK(0x01);       /* 1-kHz clock source */

  /* WDOG_CS1: EN=0,INT=0,UPDATE=1,TST=0,DBG=0,WAIT=1,STOP=1 */

  WDOG_CS1 = WDOG_CS1_UPDATE_MASK |

             WDOG_CS1_TST(0x00) |

             WDOG_CS1_WAIT_MASK |

             WDOG_CS1_STOP_MASK;

 

  /* System clock initialization */

  /* SIM_BUSDIV: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,BUSDIV=1 */

  SIM_BUSDIV = SIM_BUSDIV_BUSDIV_MASK; /* Update system prescalers */

  /* Switch to FEI Mode */

  /* ICS_C1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */

  ICS_C1 = ICS_C1_CLKS(0x00) |

           ICS_C1_RDIV(0x00) |

           ICS_C1_IREFS_MASK |

           ICS_C1_IRCLKEN_MASK;

  /* ICS_C2: BDIV=0,LP=0 */

  ICS_C2 &= (uint8_t)~(uint8_t)((ICS_C2_BDIV(0x07) | ICS_C2_LP_MASK));

  /* OSC_CR: OSCEN=0,??=0,OSCSTEN=0,OSCOS=0,??=0,RANGE=0,HGO=0,OSCINIT=0 */

  OSC_CR = 0x00U;

  while((ICS_S & ICS_S_IREFST_MASK) == 0x00U) { /* Check that the source of the FLL reference clock is the internal reference clock. */

  }

  while((ICS_S & 0x0CU) != 0x00U) {    /* Wait until output of the FLL is selected */

  }

  /*** End of PE initialization code after reset ***/

  /*** !!! Here you can place your own code after PE initialization using property "User code after PE initialization" on the build options tab. !!! ***/

}

 

 

Issue 2:

On P.E. Component Inspector, editing "Cpu", setting "ICS Mode" to FBELP, the actual clock code is not generated on file Cpu.c.

I actually intend to use using FBELP with a 10Mhz oscillator (for better precision), so I really need to know how to fix this! Here is the __init_hardware generated code:

 

void __init_hardware(void)

{

  /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/

  /*** ### MKE02Z16VLC4 "Cpu" init code ... ***/

  /*** PE initialization code after reset ***/

  SCB_VTOR = (uint32_t)(&__vect_table); /* Set the interrupt vector table position */

  /* Disable the WDOG module */

  /* WDOG_TOVAL: TOVAL=0xE803 */

  WDOG_TOVAL = WDOG_TOVAL_TOVAL(0xE803); /* Timeout value */

  /* WDOG_CS2: WIN=0,FLG=0,??=0,PRES=0,??=0,??=0,CLK=1 */

  WDOG_CS2 = WDOG_CS2_CLK(0x01);       /* 1-kHz clock source */

  /* WDOG_CS1: EN=0,INT=0,UPDATE=1,TST=0,DBG=0,WAIT=1,STOP=1 */

  WDOG_CS1 = WDOG_CS1_UPDATE_MASK |

             WDOG_CS1_TST(0x00) |

             WDOG_CS1_WAIT_MASK |

             WDOG_CS1_STOP_MASK;

 

  /* System clock initialization */

  /* SIM_BUSDIV: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,BUSDIV=1 */

  SIM_BUSDIV = SIM_BUSDIV_BUSDIV_MASK; /* Update system prescalers */

Where is the code?!

  /*** End of PE initialization code after reset ***/

  /*** !!! Here you can place your own code after PE initialization using property "User code after PE initialization" on the build options tab. !!! ***/

}

 

 

If you need any other information, please ask.

Thanks a lot!

Attachments

Outcomes