AnsweredAssumed Answered

Switching to 2MHz clock stops in bsp

Question asked by Tom Paden on Apr 21, 2015
Latest reply on Apr 23, 2015 by soledad

I'm using IAR 7.3, MQX 4.1.1, K70. When I perform a switch to 2MHz clock it runs away in Cpu_SetMCGModeFBI(CLKMode),

right at line MCG_C1 = (uint8_t)0x46U; neer gets past that. As if something is interrupting it.

and eventually breaks with [KERNEL_DATA$$Limit + 0x387c] in the call stack window.

 

/* Switch to FBI Mode */

      /* MCG_C1: CLKS=1,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */

      MCG_C1 = (uint8_t)0x46U;

      /* MCG_C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=0,LP=0,IRCS=1 */

      MCG_C2 = (uint8_t)0x21U;

      /* MCG_C4: DMX32=0,DRST_DRS=0 */

      MCG_C4 &= (uint8_t)~(uint8_t)0xE0U;

      /* OSC0_CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */

      OSC0_CR = (uint8_t)0x00U;

      /* MCG_C10: LOCRE2=0,??=0,RANGE1=2,HGO1=1,EREFS1=1,??=0,??=0 */

      MCG_C10 = (uint8_t)0x2CU;

      /* OSC1_CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */

      OSC1_CR = (uint8_t)0x00U;

      /* MCG_C7: OSCSEL=0 */

      MCG_C7 &= (uint8_t)~(uint8_t)0x01U;

      /* MCG_C5: PLLREFSEL0=0,PLLCLKEN0=0,PLLSTEN0=0,??=0,??=0,PRDIV0=0 */

      MCG_C5 = (uint8_t)0x00U;

       /* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0 */

       MCG_C6 = (uint8_t)0x00U;             /* 7 */

       /* MCG_C11: PLLREFSEL1=0,PLLCLKEN1=0,PLLSTEN1=0,PLLCS=0,??=0,PRDIV1=0 */

       MCG_C11 = (uint8_t)0x00U;            /* 7 */

       /* MCG_C12: LOLIE1=0,??=0,CME2=0,VDIV1=0 */

       MCG_C12 = (uint8_t)0x00U;            /* 7 */

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

      }

      while((MCG_S & 0x0CU) != 0x04U) { /* Wait until internal reference clock is selected as MCG output */

      }

      break;

    default:

      break;

Thanks,

Andy

Outcomes