Configuring K02 for external Oscillator not working.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuring K02 for external Oscillator not working.

712 Views
josephgundel
Contributor III

I have no problem when i am using internal oscillator but I need to use an external 32.768 Khz crystal the micro gets stuck here -> HWTIMER_SYS_SystickGetTime() at fsl_hwtimer_systick.c:357 0x4cd8   

Thread [1] <main> (Suspended : Signal : SIGINT:Interrupt)   

    HWTIMER_SYS_SystickGetTime() at fsl_hwtimer_systick.c:357 0x4cd8   

    HWTIMER_SYS_GetTime() at fsl_hwtimer.c:376 0x4b54   

    _bsp_get_hwticks() at init_bsp.c:330 0x467a   

    _time_notify_kernel() at time.c:2,178 0x4592   

    HWTIMER_SYS_SystickIsr() at fsl_hwtimer_systick.c:113 0x4bb2   

    _isr_execute() at dispatch.S:644 0x1bda   

    _isr_execute() at dispatch.S:644 0x1bda   

    _isr_execute() at dispatch.S:644 0x1bda   

    _isr_execute() at dispatch.S:644 0x1bda   

    _isr_execute() at dispatch.S:644 0x1bda   

    <...more frames...>   

Here is my configuration:

#define CPU_XTAL_CLK_HZ           32768U         /* Value of the external crystal or oscillator clock frequency of the system oscillator (OSC) in Hz */
#define CPU_XTAL32k_CLK_HZ        0U             /* No RTC clock available */
#define CPU_INT_SLOW_CLK_HZ       32768U         /* Value of the slow internal oscillator clock frequency in Hz */
#define CPU_INT_FAST_CLK_HZ       4000000U       /* Value of the fast internal oscillator clock frequency in Hz */
#define CPU_INT_IRC_CLK_HZ        48000000U     

/* Value of the 48M internal oscillator clock frequency in Hz */

#define DEFAULT_SYSTEM_CLOCK    95977472U      /* Default System clock value */
  #define MCG_MODE                MCG_MODE_FEE /* Clock generator mode */

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

  #define SYSTEM_MCG_C1_VALUE     0x02U          /* MCG_C1 */

  /* MCG_C2: LOCRE0=0,FCFTRIM=0,RANGE=0,HGO=0,EREFS=1,LP=0,IRCS=0 */

  #define SYSTEM_MCG_C2_VALUE     0x04U          /* MCG_C2 */

  /* MCG_C4: DMX32=1,DRST_DRS=3,FCTRIM=0,SCFTRIM=0 */

  #define SYSTEM_MCG_C4_VALUE     0xE0U          /* MCG_C4 */

  /* MCG_SC: ATME=0,ATMS=0,ATMF=0,FLTPRSRV=0,FCRDIV=0,LOCS0=0 */

  #define SYSTEM_MCG_SC_VALUE     0x00U          /* MCG_SC */

  /* MCG_C5:  */

  #define SYSTEM_MCG_C5_VALUE     0x00U          /* MCG_C5 */

  /* MCG_C6: CME=0 */

  #define SYSTEM_MCG_C6_VALUE     0x00U          /* MCG_C6 */

  /* MCG_C7: OSCSEL=0 */

  #define SYSTEM_MCG_C7_VALUE     0x00U          /* MCG_C7 */

  /* OSC_CR: ERCLKEN=1,EREFSTEN=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */

  #define SYSTEM_OSC_CR_VALUE     0x80U          /* OSC_CR */
  #define SYSTEM_SMC_PMCTRL_VALUE 0x60U          /* SMC_PMCTRL */

  /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=1,OUTDIV4=3 */

  #define SYSTEM_SIM_CLKDIV1_VALUE0x01030000U    /* SIM_CLKDIV1 */

  /* SIM_SOPT1: OSC32KSEL=2,OSC32KOUT=0,RAMSIZE=0 */

  #define SYSTEM_SIM_SOPT1_VALUE  0x00080000U    /* SIM_SOPT1 */

  /* SIM_SOPT2: PLLFLLSEL=0,TRACECLKSEL=0,CLKOUTSEL=0 */

  #define SYSTEM_SIM_SOPT2_VALUE  0x00U         

/* SIM_SOPT2 */

Labels (1)
Tags (1)
0 Kudos
Reply
1 Reply

512 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Joesph Gundel,

   SystickGetTime is the systick module operation, the full function is like this :

static _hwtimer_error_code_t HWTIMER_SYS_SystickGetTime(hwtimer_t *hwtimer, hwtimer_time_t *time)

{

    uint32_t tempVal;

    assert(NULL != hwtimer);

    assert(NULL != time);

    /* Enter critical section to avoid disabling interrupt from pit for very long time */

    OSA_EnterCritical(kCriticalDisableInt);

    SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;

    time->ticks = hwtimer->ticks;

    tempVal = SysTick->VAL;

    /* Check systick pending interrupt flag */

    if (SCB->ICSR & SCB_ICSR_PENDSTSET_Msk)

    {

        SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;

        OSA_ExitCritical(kCriticalDisableInt);

        time->subTicks = hwtimer->modulo - 1U;

    }

    else

    {

        SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;

        OSA_ExitCritical(kCriticalDisableInt);

        /* interrupt flag is set upon 1->0 transition, not upon reload - wrap around */

        time->subTicks = SysTick->LOAD - tempVal + 1U;

    }

    return kHwtimerSuccess;

}

Which line you are stopping? You can comment the systick operation, to check whether your can enter in main function.

Besides, you can define

  #define SYSTEM_SMC_PMCTRL_VALUE 0x00U          /* SMC_PMCTRL */

Just work in run mode, instead of fast run mode, then check whether you can work ok?

Wish it helps you!

Regards,

Jingjing

0 Kudos
Reply