Timer usage

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

Timer usage

438件の閲覧回数
Darshan_The_Gee
Contributor I

Helllo,

 

I am using the MC9S12XE-family and I would like to use a timer.

 

The timer should be started for an indefinite time. And after a particular time I want to stop the timer.

 

Also I want to measure the time the timer was running for?

 

Does anybody have any idea which timer and how can I do it?

 

Cheeers,

DArshan

ラベル(1)
0 件の賞賛
1 返信

278件の閲覧回数
kef
Specialist I

ECT, TIM, PIT timers, and even RTI (real time interrupt) are suitable for the task. You can even count the time using ATD (analog to digital module) interrupt. It's not necessary to stop the timer. Instead you can notice starting and ending timer count and calculate the difference.

ECT and TIM are very simple to use for short timer intervals, less that 2^16 timer ticks. You read starting TCNT value, read ending TCNT value and take the differemce. For longer times you need to enable timer overflow interrupt and count overflow events. Overflow counter combined with TCNT can help you extending timer bitness from 16bit to as much bits as you need.

Alternatively you can use any other periodic interrupt (RTI, PIT, ..) and count interrupt events. Since interrupt period is known, you can use interupt counter variable as a timer.

So you should just open the datasheet and go reading about these peripheral modules. Good luck.

0 件の賞賛