kl43z timer issue

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,354件の閲覧回数
kennethgraakjær
Contributor II

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?

タグ(2)
0 件の賞賛
返信
1 解決策
1,236件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,237件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
1,236件の閲覧回数
kennethgraakjær
Contributor II

Worked like a charm! Thank you.

I had the clock source in SIM_SOPT2 confused with the clock gate.

0 件の賞賛
返信