I am using TPM0 to generate a PWM on a pin, I want the the CMP0 Output to trigger the start/restart of the PWM output. To produce a timed pulse based upon the specified duty cycle.
I've set the PWM to Stop on overflow and start on trigger, set the trigger to 1, which the KL27 Sub-Family Reference Manual page 335 says is the CMP0 output
TimerConf.enableStopOnOverflow = true;
TimerConf.enableStartOnTrigger = true;
TimerConf.triggerSelect = kTPM_Trigger_Select_1;
TimerConf.triggerSource = kTPM_TriggerSource_Internal;
But the timer doesn't get restarted by the CMP0 trigger,
I know the CMP0 is firing as I see it's interrupt occurring.
If I change the TPM0 trigger source to use an external pin :
TimerConf.triggerSelect = kTPM_Trigger_Select_0;
TimerConf.triggerSource = kTPM_TriggerSource_External;
This works and the PWM counter gets reset and the TPM is started.
I need to use the CMP to trigger the timer though as the input has noise and it want to use its filtering abilities.
Another question, if I can't get the above to work, how do you restart a timer that has stopped when using
enableStopOnOverflow. I could do this from the functioning CMP0 interrupt then.