Hi
I'm trying to do a bare bones timer setup on the frdm kl43z board.
In my source I have:
#include "fsl_device_registers.h"
int main() {
TPM2_SC |= TPM_SC_PS(0x7); // prescaler at 128.
/* other stuff */
}
However when I encounter the above line in debug mode it triggers the default interrupt handler. This is the same for all timers TPM0 - 2.
Any ideas as to what I'm missing?
Solved! Go to Solution.
Hello Kenneth Graakjaer:
Have you enabled the clock gate for TPM2?
This must be done before configuring any TPM2 register. The line of code would be this:
SIM_SCGC6 |= SIM_SCGC6_TPM2_MASK;
This applies to any peripheral; before accesing the registers you have to enable the clock gates.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Kenneth Graakjaer:
Have you enabled the clock gate for TPM2?
This must be done before configuring any TPM2 register. The line of code would be this:
SIM_SCGC6 |= SIM_SCGC6_TPM2_MASK;
This applies to any peripheral; before accesing the registers you have to enable the clock gates.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Worked like a charm! Thank you.
I had the clock source in SIM_SOPT2 confused with the clock gate.