I am performing a simple test to generate pulses from a ECT pin. I am measuring an unexpectedly large (4-8uS) amount of jitter with my o-scope. My system requires much tighter control of the timer outputs than this. Here are more details...
MC9S12XDT256 running with 16MHz xtal and PLL set for 40MHz.
The PTPSR is set to 19 which should result in a 500nS time base for TCNT.
The test simply reads the TCTL2_OL bit for that channel and calls a different function if the edge was just commanded to go high or low. Then both functions add a constant value (2000) to the TCx register in the OC isr and set or clear the TCLT2_OL bit for the next edge. So, this should result in a 1mS square wave. With my o-scope it measures between 9992uS and 9996uS. So, the center isn't even around 1mS (always short) and there is about 4uS of jitter.
I tried this with the TCTL2_Ox settings to toggle on output compare and the jitter went away. Does the changing of the TCTL2_OL bit in my ISR somehow mess up the output compare time?
In my application, I need to handle the high time and low time seperately and this seems like the best way to handle it. If I use PTIT to query the state of the pin, it could possibly be delayed due to line capacitance, etc. and execute the wrong function. Am I wrong about this? Is there a register bit that I can read that would represent the commanded pin state when TCTL2_Ox is set for toggle action?
Does anyone else have any ideas on what the best way to handle this is?