Triggering TPM0 Start on CMP0 MKL27Z32

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

Triggering TPM0 Start on CMP0 MKL27Z32

990件の閲覧回数
carl-circuitwor
Contributor II

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

TPM_GetDefaultConfig(&TimerConf);
TimerConf.enableStopOnOverflow = true;
TimerConf.enableStartOnTrigger = true;

TimerConf.triggerSelect = kTPM_Trigger_Select_1;
TimerConf.triggerSource = kTPM_TriggerSource_Internal;

TPM_Init(TPM0, &TimerConf);

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.

Any Advice?

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.

Thanks

ラベル(1)
0 件の賞賛
返信
1 返信

870件の閲覧回数
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Carl,

Please try to use the code shown below:

TimerConf.triggerSelect = kTPM_Trigger_Select_1;
TimerConf.triggerSource = kTPM_TriggerSource_External;

external trigger options.jpg

 

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信