Free-running timer TPM on KL17Z

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Free-running timer TPM on KL17Z

ソリューションへジャンプ
1,024件の閲覧回数
gschelotto
Contributor V

Hi,

I'd need to implement a free-running timer using TPM timer without IRQ in order to get successive time-stamps between acquisition data samples. I know the concept is easy and trivial but I'm trying to do it using the latest SDK for KL17Z with no success. I'm also not able to find any TPM SDK examples with such behavior. Can anyone help me with this problem?

regards,
gaston

0 件の賞賛
返信
1 解決策
932件の閲覧回数
gschelotto
Contributor V

Solved.

At the end I used the Systick timer as free-running timer and it works as expected. Here's the code inside the sampling routine

    tmp = SysTick->VAL;

    // SysTick Reload Value register supports values between 1 and 0x00FFFFFF.
    SysTick->LOAD = 0x00FFFFFF;
    SysTick->VAL = 0;

    tmp = 0x00FFFFFF - tmp;
    timeStamp[tmStmpIdx] = COUNT_TO_USEC(tmp, CLOCK_GetFreq(kCLOCK_CoreSysClk));
    tmStmpIdx++;
‍‍‍‍‍‍‍‍‍‍

thanks,
gaston

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
932件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi gaston,

Have you try to refer the tpm_timer example in SDK_2.7.0_MKL17Z64xxx4?

tpm_timer.png
enableStopOnOverflow = false; means TPM counter continues running after overflow.
You can disable below IRQ related codes.

enableStopOnOverflow.png

Seems that you don't need to interrupt 1ms anymore, so configure MOD=0xffff by using TPM_SetTimerPeriod function.

TPM_SetTimerPeriod.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
932件の閲覧回数
gschelotto
Contributor V

Yes indeed, I proceed as you suggested and the timer is running as expected but writing this code in my IRQ sampling process

timeStamp[tmStmpIdx] = TPM_GetCurrentTimerCount(TPM2);
tmStmpIdx++;

leads to the same results on the timeStamp array and I cannot see any increment on their values. Any hint?

How can I reset the timer counter?

regards,

gaston

0 件の賞賛
返信
933件の閲覧回数
gschelotto
Contributor V

Solved.

At the end I used the Systick timer as free-running timer and it works as expected. Here's the code inside the sampling routine

    tmp = SysTick->VAL;

    // SysTick Reload Value register supports values between 1 and 0x00FFFFFF.
    SysTick->LOAD = 0x00FFFFFF;
    SysTick->VAL = 0;

    tmp = 0x00FFFFFF - tmp;
    timeStamp[tmStmpIdx] = COUNT_TO_USEC(tmp, CLOCK_GetFreq(kCLOCK_CoreSysClk));
    tmStmpIdx++;
‍‍‍‍‍‍‍‍‍‍

thanks,
gaston

0 件の賞賛
返信