The K344 uses polling to capture PWM duty cycles (emphasis: no interruptions)

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

The K344 uses polling to capture PWM duty cycles (emphasis: no interruptions)

跳至解决方案
726 次查看
jiafeimao
Contributor III

I want to use 344MCU to capture a way of PWM duty cycle, it seems that only with interrupts + SAIC mode to achieve duty cycle capture, but I can not use interrupts. I figured out if I could configure two pins, one pin to capture the pulse width (IPWM mode) , the other pin to capture the pulse frequency (IPM mode) , then connect the two pins together and then connect the PWM waveform to be captured, ah, with the pulse width and pulse frequency to get the duty cycle.

 

What I don't understand is that if I connect the two pins of the MCU together, will the two pins interfere with each other while capturing the PWM signal?

0 项奖励
回复
1 解答
683 次查看
jiafeimao
Contributor III
I tested the example, found that the PWM cycle and duty cycle can be obtained under interruption conditions.
Afterwards, I regenerated the code and removed the interrupt enable and interrupt interface. In non interrupt situations, both the cycle and duty cycle were returned as 0.
In addition, I use IPWM and IPM to capture a PWM signal (two pins). IPWM obtains a high level, IPM obtains a cycle, and the duty cycle can be obtained without any interruption.I think this is the only way to obtain the PWM duty cycle without any interruption. Here is my approach:
1.Pin settings:
jiafeimao_0-1718154788174.png

2.Emios_Mcl_Ip:

jiafeimao_1-1718154899157.png

3.Emios_Icu:

jiafeimao_2-1718154991603.pngjiafeimao_3-1718155012661.pngjiafeimao_4-1718155035252.png
jiafeimao_5-1718155052081.png

4.demo init ipwm and ipm:

jiafeimao_6-1718155165895.png

5.demo get duty:

jiafeimao_9-1718155383270.png

 


 


 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
692 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

Have you already referred to S32K344_Example_Emios_Icu_IPWM_measurement_DS34_RTD_100_v2

If you want to use polling method instead of interrupt method, please poll the status via Emios_Icu_Ip_GetInputState before calling Emios_Icu_Ip_GetDutyCycleValues.

Since I don't know the S32K3 RTD version you are using, I sent you the S32K344_Example_Emios_Icu_IPWM_measurement_S32DS35_RTD400.zip through private message. It is recommended to modify it to the polling mode based on project. Sorry, I haven't had time to test the polling method for you because I have been dealing with a lot of cases recently. If you still can't implement it after the modification, please let me know.


Best Regards,
Robin
-------------------------------------------------------------------------------
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 项奖励
回复
528 次查看
rthym
Contributor II
hi,我最近在做速度采集的时候也遇到了困扰,可以把S32K344_Example_Emios_Icu_IPWM_measurement_S32DS35_RTD400.zip 这个给我分享一下吗
0 项奖励
回复
505 次查看
jiafeimao
Contributor III

Sorry, I just noticed the message now. Here is the program provided by technical support, but it should still be the interrupt capture PWM duty cycle method. The actual implementation using polling can be seen in my solution below, which has been verified.

0 项奖励
回复
684 次查看
jiafeimao
Contributor III
I tested the example, found that the PWM cycle and duty cycle can be obtained under interruption conditions.
Afterwards, I regenerated the code and removed the interrupt enable and interrupt interface. In non interrupt situations, both the cycle and duty cycle were returned as 0.
In addition, I use IPWM and IPM to capture a PWM signal (two pins). IPWM obtains a high level, IPM obtains a cycle, and the duty cycle can be obtained without any interruption.I think this is the only way to obtain the PWM duty cycle without any interruption. Here is my approach:
1.Pin settings:
jiafeimao_0-1718154788174.png

2.Emios_Mcl_Ip:

jiafeimao_1-1718154899157.png

3.Emios_Icu:

jiafeimao_2-1718154991603.pngjiafeimao_3-1718155012661.pngjiafeimao_4-1718155035252.png
jiafeimao_5-1718155052081.png

4.demo init ipwm and ipm:

jiafeimao_6-1718155165895.png

5.demo get duty:

jiafeimao_9-1718155383270.png

 


 


 

0 项奖励
回复