Dao Yan Lim

Kinetis K60 LPTMR module in interrupt mode

Discussion created by Dao Yan Lim on Sep 21, 2016
Latest reply on Sep 21, 2016 by Dao Yan Lim



I am using TWR-K60N512, with PK60DN512Z VMD10 chip and Codewarrior 10.5. There's a very good example baremetal project for this module, but the interrupt mode in this example doesn't work properly. I think it got stuck in the interrupt and keeps printing 'LPT ISR' every five seconds.The code is shown below taken directly from the example. It does not ever go beyond the "while(LPTMR_INTERRUPT == 0)" line.


Any idea how to troubleshoot this? To view the full example "lptmr project", you can find it in Codewarrior example for K60.



void lptmr_interrupt(void)
   int compare_value=5000; //value must be less than 0xFFFF
   LPTMR_INTERRUPT=0; //Clear global variable
   enable_irq(85); //LPTMR Vector is 101. IRQ# is 101-16=85
   LPTMR0_CMR=LPTMR_CMR_COMPARE(compare_value); //Set compare value
   LPTMR0_CSR=LPTMR_CSR_TIE_MASK; //Enable LPT interrupt
   in_char(); //wait for keyboard press

   LPTMR0_CSR|=LPTMR_CSR_TEN_MASK; //Turn on LPTMR and start counting

   while(LPTMR_INTERRUPT == 0)


******NEVER GOT TO THIS LINE**********


   LPTMR0_CSR&=~LPTMR_CSR_TEN_MASK; //Turn off LPT to avoid more interrupts


void lptmr_isr(void)
   LPTMR0_CSR|=LPTMR_CSR_TCF_MASK; //Clear LPT Compare flag
   LPTMR_INTERRUPT=1; //Set global variable
   printf("\n\nIn LPT ISR!\n\n"); ************ THIS KEEPS PRINTING *********