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.
已解决! 转到解答。
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,
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