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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,783 Views
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
Labels (1)
0 Kudos
3 Replies

342 Views
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 Kudos

342 Views
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 Kudos

342 Views
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 Kudos