AnsweredAssumed Answered

LPTMR interrupt stuck in Default ISR - KL46, KDS, SDK 2

Question asked by Carlos Mendoza on Nov 13, 2016
Latest reply on Nov 14, 2016 by Carlos_Mendoza



I'm hoping to trigger sampling from the ADC module using the low power timer's modulo counter interrupt. This is the interrupt that's generated when the value in the counter register CNR is equal to the value in the compare register CMR. However, running the code causes the microcontroller to loop indefinitely in the "DefaultISR". My best guess is that the microcontroller generates the interrupt and attempts to service it but then the microcontroller doesn't know which ISR to call so it gets stuck looping through the default ISR.


I'm using an FRDM-KL46 board, KDS and the SDK 2.0. I have successfully triggered the ADC module on this MCU with both the lptmr and the Timer PWM module using CodeWarrior 10.6 and Processor Expert. But, I'm hoping to learn how to do this using KDS and the SDK 2.0.


Troubleshooting reveals the following hints:


1) Pausing execution and stepping through the code shows that the microcontroller configured the LPTMR registers correctly and that in fact the LPTMR's interrupt is generated. I can tell because the LPTMR's control and status register CSR has its timer compare flag bit TCF set to 1 when the code "hangs" and yet TCF was set to zero before hanging. I can also see that the CNR register reached the desired value. I know that the configuration is correct because I'm comparing my code against the LPTMR example that comes with the SDK 2.0 and that code works without problems.


Moreover, my code gets stuck looping in the "DefaultISR" code in "startup_MKL46Z4.S" line 190. Here the code loads the address of the "DefaultISR" into register r0 and then it jumps to this address. Thus, the code loops indefinitely jumping again into the DefaultISR instead of jumping to the LPTMR's ISR or whatever intermediate steps before eventually jumping to my LPTMR's ISR.


2) When I compile I get the following warning and additional information:


'LPTMR0_IRQHandler' defined but not used [-Wunused-function]
in expansion of macro 'LPTMR_LED_HANDLER'


I don't get this warning when I compile the LPTMR example included with the SDK 2.0. So this leads me to think that my LPTMR's ISR is not being "installed" in the vector table.


I understand that in the SDK 2.0, instead of installing ISRs we just name them using a standardized convention defined at the interrupt vector table in "startup_MKL46Z4.S". Then if we want to name the ISRs something else for convenience's sake then we just use a define statement. I'm using the definition LPTMR_LED_HANDLER as an alias for LPTMR0_IRQHandler just like it's done in the working LPTMR example provided with the SDK 2.0.


3) Last hint: in my code I have included some CMSIS header files because that's what I saw done in the ADC example provided in the SDK 2.0. I'm still not sure why this is done. However, one of these header files, "MKL46Z4.h" contains the statement LPTimer_IRQHandler which is defined as LPTMR0_IRQHandler. That code section has the comment "SDK_Compatibility_Symbols". Therefore, twice in the code I have statements that are aliases for "LPTMR0_IRQHandler". This made me think that perhaps the presence of the CMSIS headers is generating a conflict with the interrupt vector table. If I comment out the  LPTimer_IRQHandler define statement in the CMSIS file then I no longer get the compiler warning about my LPTMR's ISR being defined but not used. The code still gets stuck looping in the DefaultISR but at least this gives me an additional hint of what the problem might be.


That's all I have for now. I wouldn't be surprised if there's a very easy fix for this problem or a simple detail I'm overlooking.


Any troubleshooting ideas would help a lot. Many thanks in advance!






#kds 3.2.0

#sdk 2