change frequency at runtime for PWM in mcuexpresso for FRDM-KL25Z

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

change frequency at runtime for PWM in mcuexpresso for FRDM-KL25Z

ソリューションへジャンプ
2,703件の閲覧回数
tims123
Contributor I

I wanted to change frequency of PWM at runtime to ramp the stepper motor.

I looked at various options like PPG, but its not available on mcuxpresso or i didn't find it. 

Please help.

0 件の賞賛
返信
1 解決策
2,693件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi tims123

   Do you use the TPM to output the PWM?

   If yes, if you want to change the PWM frequency , you can change your TPMx_MOD, 

  More details, please check the KL25 reference manual:

https://www.nxp.com/docs/en/reference-manual/KL25P80M48SF0RM.pdf

 chapter 31.4.8.1 MOD Register Update

 

31.4.8.1 MOD Register Update
If (CMOD[1:0] = 0:0) then MOD register is updated when MOD register is written.
If (CMOD[1:0] ≠ 0:0), then MOD register is updated according to the CPWMS bit, that
is:
• If the selected mode is not CPWM then MOD register is updated after MOD register
was written and the TPM counter changes from MOD to zero.
• If the selected mode is CPWM then MOD register is updated after MOD register was
written and the TPM counter changes from MOD to (MOD – 1).

 

Wish it helps you!

If you still have questions about it, please kindly let me know!

Best Regards,

Kerry

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-----------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
2,664件の閲覧回数
tims123
Contributor I

Used Timers in my application for now. 

 

Implementing Frequency change in fsl_tpm.h API would be great though.

 

Closing the issue.

0 件の賞賛
返信
2,648件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi tims123

   Thanks for your updated information.

    Any new questions in the future, welcome to create the new question post!

 

Best Regards,

Kerry

0 件の賞賛
返信
2,694件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi tims123

   Do you use the TPM to output the PWM?

   If yes, if you want to change the PWM frequency , you can change your TPMx_MOD, 

  More details, please check the KL25 reference manual:

https://www.nxp.com/docs/en/reference-manual/KL25P80M48SF0RM.pdf

 chapter 31.4.8.1 MOD Register Update

 

31.4.8.1 MOD Register Update
If (CMOD[1:0] = 0:0) then MOD register is updated when MOD register is written.
If (CMOD[1:0] ≠ 0:0), then MOD register is updated according to the CPWMS bit, that
is:
• If the selected mode is not CPWM then MOD register is updated after MOD register
was written and the TPM counter changes from MOD to zero.
• If the selected mode is CPWM then MOD register is updated after MOD register was
written and the TPM counter changes from MOD to (MOD – 1).

 

Wish it helps you!

If you still have questions about it, please kindly let me know!

Best Regards,

Kerry

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-----------------------------------------------------------------------------

0 件の賞賛
返信
2,689件の閲覧回数
tims123
Contributor I

I'm using the fsl_tpm.h API, it has a method to update PWM duty cycle , but not Frequency or Time Period. will try updating MOD register and will let you know.

0 件の賞賛
返信
2,680件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

HI tims123

   Ok, you can try it at first.

   Any updated information from your side, just feel free to let me know.

 

Best Regards,

Kerry

0 件の賞賛
返信