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
解決済! 解決策の投稿を見る。
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
Hi gaston,
Have you try to refer the tpm_timer example in SDK_2.7.0_MKL17Z64xxx4?
enableStopOnOverflow = false; means TPM counter continues running after overflow.
You can disable below IRQ related codes.
Seems that you don't need to interrupt 1ms anymore, so configure MOD=0xffff by using TPM_SetTimerPeriod function.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
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
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