AnsweredAssumed Answered

No interrupts with MKL04 PIT

Question asked by James Millard on Aug 16, 2017
Latest reply on Aug 21, 2017 by Robin_Shen

I am having an issue with the MKL04Z8VFK4 PIT setup.  I've used the following code for years on various Kinetis controllers:

 

  PIT_MCR     = 0x0;

  PIT_LDVAL1  = 20000L;

  PIT_TCTRL1  = PIT_TCTRL_TIE_MASK;

  PIT_TCTRL1 |= PIT_TCTRL_TEN_MASK;

  enable_irq(PIT_IRQn);

 

enable_irq calls NVIC_EnableIRQ. 

 

Also, in main before the timer is initialized, the following is set:

 

  SIM_SCGC6 |= SIM_SCGC6_PIT_MASK |

               SIM_SCGC6_ADC0_MASK;

 

For some reason with this microcontroller, I'm not getting any interrupts.

 

In checking the documentation, the reference manual, KL04P48M48SF1RM.pdf, lists the TIE and TEN bits as bits 30 and 31 of the PIT_TCTRLn registers (these registers are numbered backwards compared to other registers in the same pdf file).  The PIT_TCTLR_TIE_MASK is declared as 0x2u and PIT_TCTRL_TEN_MASK is declared as 0x1u in MKL04Z4.h which is automatically included when the project was created.

 

I have stepped through all the code to make sure everything is being executed.  Interrupts are enabled by calling EnableInterrupts declared as:

 

#define EnableInterrupts __asm(" CPSIE i");

 

So two things -- it appears as though either the include file, or the documentation is wrong (see attached files).  Also, I've tried it both ways and interrupts are not happening.  

 

Any suggestions?

 

Thanks.

Original Attachment has been moved to: MKL04Z4.h.zip

Attachments

Outcomes