K32L2B21: generate PWM with variable frequency

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

K32L2B21: generate PWM with variable frequency

ソリューションへジャンプ
779件の閲覧回数
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 解決策
770件の閲覧回数
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 返信
771件の閲覧回数
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