K32L2B21: generate PWM with variable frequency

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

K32L2B21: generate PWM with variable frequency

跳至解决方案
1,960 次查看
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.

标记 (1)
0 项奖励
回复
1 解答
1,950 次查看
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

在原帖中查看解决方案

1 回复
1,951 次查看
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