AnsweredAssumed Answered

Kwikstik PIT1 interrupt not working

Question asked by Leandro Rondon on Jul 15, 2013
Latest reply on Jul 16, 2013 by Leandro Rondon

Hi, I'm starting a development using the Kwikstik (K40).

 

I'm trying to raise two PIT interrupts (whit PIT0 and PIT1), but only the PIT0 handler function is being executed.

 

Could anyone help me and tell what is wrong?

 

Thank you.

 

void _PIT_Init(void)
{
  SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;
  PIT_MCR &= ~PIT_MCR_MDIS_MASK;
  PIT_MCR |= PIT_MCR_FRZ_MASK;
}


void _PIT0_Init(void)
{
  PIT_LDVAL0 = 4000000; // 1s


  NVICISER2 |= (unsigned long)(84%32);  
  NVICICPR2 |= (unsigned long)(84%32);


  PIT_TCTRL0 |= PIT_TCTRL_TIE_MASK;
}


void _PIT0_Enable(void)
{
  PIT_TCTRL0 |= PIT_TCTRL_TEN_MASK; 
}


void _PIT0_Disable(void)
{
  PIT_TCTRL0 &= ~PIT_TCTRL_TEN_MASK; 
}


void _PIT1_Init(void)
{
  PIT_LDVAL1 = 4000000; // 1s

  NVICISER2 |= (unsigned long)(85%32);
  NVICICPR2 |= (unsigned long)(85%32);

  PIT_TCTRL1 |= PIT_TCTRL_TIE_MASK;
}


void _PIT1_Enable(void)
{
  PIT_TCTRL1 |= PIT_TCTRL_TEN_MASK; 
}


void _PIT1_Disable(void)
{
  PIT_TCTRL1 &= ~PIT_TCTRL_TEN_MASK; 
}


















int main(void)
{
  _PIT_Init();

  _PIT0_Init();
  _PIT1_Init();

  _PIT0_Enable();
  _PIT1_Enable();
  
  /* Main loop */
  while(1)
  {
  }
}


void PIT0_IRQHandler(void)
{
  _PIT0_Disable();
  PIT_TFLG0 |= PIT_TFLG_TIF_MASK;
  _PIT0_Enable();
}




void PIT1_IRQHandler(void)
{
  _PIT1_Disable();
  PIT_TFLG1 |= PIT_TFLG_TIF_MASK;
  _PIT1_Enable();
}












Outcomes