Timer Unit; SetPeriodTicks, what is it based on?

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

Timer Unit; SetPeriodTicks, what is it based on?

ソリューションへジャンプ
2,987件の閲覧回数
marknordstrand
Contributor III

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. 

ラベル(1)
0 件の賞賛
返信
1 解決策
2,720件の閲覧回数
arpitaagarwal-b
NXP Employee
NXP Employee

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

元の投稿で解決策を見る

0 件の賞賛
返信
6 返答(返信)
2,720件の閲覧回数
arpitaagarwal-b
NXP Employee
NXP Employee

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

0 件の賞賛
返信
2,720件の閲覧回数
marknordstrand
Contributor III

Should have included this, but CW version 10.4 with a mk20dn512vlq10.

0 件の賞賛
返信
2,720件の閲覧回数
arpitaagarwal-b
NXP Employee
NXP Employee

Hello Mark,

Which module are you using for setting timer? Are you using Processor Expert?

Can you share your code?

-Arpita

0 件の賞賛
返信
2,720件の閲覧回数
marknordstrand
Contributor III

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?


0 件の賞賛
返信
2,721件の閲覧回数
arpitaagarwal-b
NXP Employee
NXP Employee

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

0 件の賞賛
返信
2,719件の閲覧回数
marknordstrand
Contributor III

Arpita,


Thanks for verifying that, it's consistent with current behavior.  Not sure what I did before.


0 件の賞賛
返信