The other day, I set up a TimerUnit with a period of 1ms. In code I called SetPeriodTicks() with a value of 10000 and until recently it was responding in the OnCounteRestart event every 10 seconds. Now it is responding every .2 ms. It took a while, but I finally noticed that this is 10000 times the counter frequency. Which of these should SetPeriodTicks() be using? Rereading the description, I can see it being either way.
Solved! Go to Solution.
Hello Mark,
I checked the code of SetPeriodTicks( ). It is changing the Load register of PIT module.
PIT_LDVAL_REG(PeripheralBase,(ChannelIdx)) = \
(uint32_t)(Value) \
This indicates that it should use input frequency and multiply it with the value passed to it.
It should not use the period. I am not sure why you observed it. You might have used something different. But since the code generation through this module will be same, thus it should always use the input frequency.
-Arpita
Hello Mark,
Which MCU you are working on? What is the code warrior version?
This information is required to check the respective PE bean.
-Arpita
Should have included this, but CW version 10.4 with a mk20dn512vlq10.
Hello Mark,
Which module are you using for setting timer? Are you using Processor Expert?
Can you share your code?
-Arpita
Arpita,
Yes, using Processor Expert and using a TimeUnit_LDD with a PIT counter. Period is 1ms. Code is in a different state at the moment, so won't be much help. Setting this test up was fairly straightforward:
In main() of ProcessorExpert.c call the timer's Init() and SetPeriodTicks() with a value of 10000. In Timer1's OnCounterRestart() callback just print that the event happened (I also added info from the RTC for reference). When first implemented it the callback reported every 10 seconds, which would be the period. Currently, it responds as if uses the input frequency. Which is the intended behavior, and any idea why it changed on me?
Hello Mark,
I checked the code of SetPeriodTicks( ). It is changing the Load register of PIT module.
PIT_LDVAL_REG(PeripheralBase,(ChannelIdx)) = \
(uint32_t)(Value) \
This indicates that it should use input frequency and multiply it with the value passed to it.
It should not use the period. I am not sure why you observed it. You might have used something different. But since the code generation through this module will be same, thus it should always use the input frequency.
-Arpita
Arpita,
Thanks for verifying that, it's consistent with current behavior. Not sure what I did before.