Output compare questions

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

Output compare questions

1,442件の閲覧回数
JohnBarber
Contributor II
Hi,
I'm using a HCS08 controller.
I use the TPM1C0 to generate a tick at 1ms.
 
Now I want to implement a timer that gives a time out if two SCI RX interrupts are separated more than 500 us.
 
Is it possible to use another channel of TPM1, say TPM1C1, and in the RX ISR after reading the received data, read the TPM1 counter value, calculate the value that corresponds to +500us, set this value as the TPM1C1 compare value, and then enable output compare interrupt?
 
In pseudo-code:
Code:
Code:ISR{  read received data  disable output compare interupt  read TPM1 counter value  calculate counter value + 500us  enable output compare for TPM1C1  set TPM1C1 compare value}

 
 Will this work?
/John
ラベル(1)
0 件の賞賛
返信
1 返信

663件の閲覧回数
bigmac
Specialist III
Hello John,
 
The method that you propose should be workable.  If the channel 1 output compare value is updated each time within the SCI receive ISR, the channel interrupt should never occur with normal SCI data spacing.  It can be likened to a COP timer reset process.
 
Once the TPM channel is initialised, you probably don't need all the steps that you have outlined.  Simply calculate the new output compare value required, and write it to TPM1C1V.  There should usually be no need to re-configure TPM1C1SC each time.
 
Regards,
Mac
 
0 件の賞賛
返信