simple PWM example for KL1x ?

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

simple PWM example for KL1x ?

1,667 次查看
johnbeale
Contributor II

New to Kinetis. I am using KDS 3.0.0 and KSDK 1.2.0, with Processor Expert 3.0.1. My target is in the MKL1x family.

So far I can name and configure output pins, and control them with GPIO_DRV_SetPinOutput() and GPIO_DRV_ClearPinOutput().  I am hoping there is something at a similar level for PWM, so that for example, after using TPM0:Init_TPM in Processor Expert to configure the timer (setting clock source, modulo count, pin output for each channel, etc.) , there is some call like PWM_SetDuty(timer, channel, value) to set the duty cycle. Can I do that?

The only Kinetis code examples I have found online do not use Processor Expert, or use some (older?) version that apparently has a PWM module.  This page Tutorial: PWM with Processor Expert | MCU on Eclipse   shows PE has a PWM module, but nothing with "PWM" in the name appears in PE for me.

I found this: Example code on how to configure the TPM as PWM in the FRDM-KL25 board

which uses set_TPM_CnV(TPM1_BASE_PTR, 0, DUTY_CYCLE); but is this function documented anywhere? Google says there is exactly one web page online containing "set_TPM_CnV" and it's in Czech...  Any assistance would be welcomed!  Thanks.

标签 (1)
标记 (3)
0 项奖励
回复
2 回复数

1,021 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, John,

This is the code for TPM module based on KL02Z. You can refer to it. Hope it can help you.

BR

XiangJun Rong

1,021 次查看
bgraham
Contributor IV

I found a demo "simple_pwm" that the uses the PWM with the board's LEDs

Thanks for the help.

Bruce

0 项奖励
回复