9S08AW60 Output Compare, using the toggle output.  Can I preset the state of the FlipFlop?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

9S08AW60 Output Compare, using the toggle output.  Can I preset the state of the FlipFlop?

2,020 次查看
TurboBob
Contributor IV
If I want to use the toggle on compare (or the set/clear on compare) to run the output pin, how do I preset the flipflop?

i.e. when I enable the function, I want the output to be a certain, known state.  How do I preset it?

Is there a way to read the state of the flipflop and let the TPM channel execute a cycle or 2 to ensure its preset properly?

Thanks

Bob Bailey
Bailey Engineering Inc
标签 (1)
0 项奖励
回复
3 回复数

579 次查看
bigmac
Specialist III
Hello Bob,
 
I presume you will be using interrupts on the TPM channel.  If you need to explicitly control the output state resulting from an output compare, I suggest you don't set for toggle mode.  Instead, select either set on compare, or clear on compare, from within the ISR, to correspond with the opposite of the current state.  The current state would be indicated by bit-2 of the channel status and control register.
 
When initialising the timer channel, and prior to enabling interrupts, the initial setting should clear on compare.  You could also read the current timer counter value, and set the initial channel compare value to occur a few timer cycles hence.
 
Regards,
Mac
 
0 项奖励
回复

579 次查看
BasePointer
Contributor II
Hi,
 
I simply set or clear the port output for that and it works for me on toggle mode.
 
PTCD_PTCD2 = 1;
 
BP.
0 项奖励
回复

579 次查看
peg
Senior Contributor IV
Hi,

Hmmm,
They seem to have dropped the output preset mode from the TPM in the S08, like in the GP32 for instance.
Perhaps the method suggested by BasePointer is sufficient.
Or in your initialisation you could set up a compare to the correct level, wait for it, then do toggles from there.

0 项奖励
回复