simple PWM example for KL1x ?

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

simple PWM example for KL1x ?

1,671 Views
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.

Labels (1)
0 Kudos
Reply
2 Replies

1,025 Views
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,025 Views
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 Kudos
Reply