Handling Timer Overflow and a Method for loading the S08QD4 TPM2 Value Register using OC Mode

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

Handling Timer Overflow and a Method for loading the S08QD4 TPM2 Value Register using OC Mode

ソリューションへジャンプ
1,285件の閲覧回数
GaugeGuy
Contributor I

Hello all,

 

I am working on a new project involving PDP and have questions in reference to the thread dealing with PDP. (Pulse Distance Protocol)

 

https://community.freescale.com/message/103280#103280

 

1. Using the TPM2 in OC Mode, do I need to deal with Timer Overflow? (I do not see any code in the thread to handle overflow)

 

2. In the TPM2 CH 0 ISR, the following code is used the load the value register:

          TPM2C0V += SPULSE;   // Start pulse (9000)

 

Is this code effectively the same as:

          TPM2C0V = TPM2CNT + SPULSE;   // Start pulse (9000)

 

Thanks,

David

ラベル(1)
0 件の賞賛
返信
1 解決策
1,054件の閲覧回数
bigmac
Specialist III

Hello David,

 

You do not need to be concerned about timer overflow provided the following conditions are met -

  1. The TPM module is free-running (TPM2MOD is 0 or 0xFFFF)
  2. The maximum timed period does not exceed the overflow period, i.e. no more than one overfow occurs during the timed period.

TPM2C0V += SPULSE;   // Start pulse (9000)

 

This is equivalent to -

TPM2C0V = TPM2COV + SPULSE;

 

The next timing interval must always be referenced from the time of the previous output compare event, when the output pin actually changed state.  Since there will always be some latency in the execution of the ISR, referencing the next compare event from the current counter value will cause timing errors.

 

Regards,

Mac

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,055件の閲覧回数
bigmac
Specialist III

Hello David,

 

You do not need to be concerned about timer overflow provided the following conditions are met -

  1. The TPM module is free-running (TPM2MOD is 0 or 0xFFFF)
  2. The maximum timed period does not exceed the overflow period, i.e. no more than one overfow occurs during the timed period.

TPM2C0V += SPULSE;   // Start pulse (9000)

 

This is equivalent to -

TPM2C0V = TPM2COV + SPULSE;

 

The next timing interval must always be referenced from the time of the previous output compare event, when the output pin actually changed state.  Since there will always be some latency in the execution of the ISR, referencing the next compare event from the current counter value will cause timing errors.

 

Regards,

Mac

 

0 件の賞賛
返信
1,054件の閲覧回数
GaugeGuy
Contributor I

Hi Mac,

 

Thanks for your explanation!

The TPM code is working as needed.

 

Thanks,
David

0 件の賞賛
返信