K32L2B21: generate PWM with variable frequency

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

K32L2B21: generate PWM with variable frequency

Jump to solution
773 Views
nre
Contributor II

Hello, I need to generate a sound with a variable frequency during time (a siren).

I'm using uC K32L2B21, library SDK_2.9.0_K32L2B21xxxxA, MCUxpresso config tools v9,  and TPM as a HW resource.
But I didn't find a way to dynamically change the frequency of a timer in a TPM library.
Pulse-Frequency-Modulation seems not supported on this chip.
I found only one timer API function that can be used for frequency changing (TPM_SetupPwm), but it entails constant period. What is the best way to generate variable frequency PWM?
Thank you in advance.

Tags (1)
0 Kudos
1 Solution
764 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @nre ,

There is a inline function in fsl_tpm.h

static inline void TPM_SetTimerPeriod(TPM_Type *base, uint32_t ticks)
{
base->MOD = ticks;
}

 

Regards,

Jing

View solution in original post

1 Reply
765 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @nre ,

There is a inline function in fsl_tpm.h

static inline void TPM_SetTimerPeriod(TPM_Type *base, uint32_t ticks)
{
base->MOD = ticks;
}

 

Regards,

Jing