Free-running timer TPM on KL17Z

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Free-running timer TPM on KL17Z

跳至解决方案
991 次查看
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 解答
899 次查看
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 回复数
899 次查看
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 项奖励
回复
899 次查看
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 项奖励
回复
900 次查看
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 项奖励
回复