AnsweredAssumed Answered

Installing interrupts with KSDK 2.0?

Question asked by Robert Baruch on Feb 13, 2016
Latest reply on Feb 14, 2016 by Jason Martin

I've only found a document for KSDK 1.2, which refers to fsl_interrupt_manager.h, which doesn't seem to exist in SDK 2.0. I did find a function InstallIRQHandler in fsl_common.c, but I'm not sure I'm using it properly. Basically, I'm trying to write a delay function:

 

static bool timerWentOff = false;

 

void timerIRQHandler() {

  PIT_StopTimer(PIT, 0);

  timerWentOff = true;

}

 

void delayMsec(uint32_t msec) {

  timerWentOff = false;

  PIT_SetTimerPeriod(PIT, 0, (uint32_t) MSEC_TO_COUNT(msec, CLOCK_GetBusClkFreq()));

  PIT_StartTimer(PIT, 0);

  while (!timerWentOff);

}

 

void initTimerModule() {

  CLOCK_EnableClock(kCLOCK_Pit0);

  pit_config_t timerConfig = {

    .enableRunInDebug = true,

  };

  PIT_Init(PIT, &timerConfig);

  EnableIRQ(PIT0_IRQn);

  InstallIRQHandler(PIT0_IRQn, (uint32_t) timerIRQHandler);

}

 

And then in main, something like:

 

  for (;;) {

    delayMsec(100);

    LED_RED_TOGGLE();

  }

 

However, when I hit InstallIRQHandler, I get a hard fault. What's the right procedure to install an interrupt?

Outcomes