S32K312 PWM Measurement

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

S32K312 PWM Measurement

1,764件の閲覧回数
fengba_360
Contributor III

Hello, I have some questions regarding using the S32K312 EMIOS ICU for PWM measurement, and I would like to consult with you.

I am encountering an issue where the measured PWM period and duty cycle are both zero, but when I check the input pin with an oscilloscope, I can see a PWM wave being input.

Here is my code and configuration:

#define EMIOS_PWMIN_CHANNEL_1 2U /* EMIOS0 Channel 2 */
#define EMIOS_PWMIN_CHANNEL_2 3U /* EMIOS0 Channel 3 */

// Step 1: ICU Initialization
Emios_Mcl_Ip_Init(EMIOS_INSTANCE_0, &Emios_Mcl_Ip_0_Config_BOARD_INITPERIPHERALS);
Emios_Mcl_Ip_Init(EMIOS_INSTANCE_1, &Emios_Mcl_Ip_1_Config_BOARD_INITPERIPHERALS);
Emios_Icu_Ip_Init(0, &eMios_Icu_Ip_0_Config_PB);
IntCtrl_Ip_EnableIrq(EMIOS0_5_IRQn);
IntCtrl_Ip_InstallHandler(EMIOS0_5_IRQn, &EMIOS0_5_IRQ, NULL_PTR);
Emios_Icu_Ip_StartSignalMeasurement(0, EMIOS_PWMIN_CHANNEL_1);
Emios_Icu_Ip_StartSignalMeasurement(0, EMIOS_PWMIN_CHANNEL_2);

// Step 2: Running the following code at a 10ms interval
PWM_IN_1.period = 1000 * (float32)eMios_Icu_Ip_ChState[0].eMios_Icu_Ip_aPeriod /
(float32)Clock_Ip_GetClockFrequency(EMIOS0_CLK);
PWM_IN_1.duty = (float32)eMios_Icu_Ip_ChState[0].eMios_Icu_Ip_aActivePulseWidth /
(float32)(eMios_Icu_Ip_ChState[0].eMios_Icu_Ip_aPeriod + 1);

PWM_IN_2.period = 1000 * (float32)eMios_Icu_Ip_ChState[1].eMios_Icu_Ip_aPeriod /
(float32)Clock_Ip_GetClockFrequency(EMIOS0_CLK);
PWM_IN_2.duty = (float32)eMios_Icu_Ip_ChState[1].eMios_Icu_Ip_aActivePulseWidth /
(float32)(eMios_Icu_Ip_ChState[1].eMios_Icu_Ip_aPeriod + 1);

1-1.png1-2.png1-3.png1-4.png1-5.png1-6.png1-7.png1-8.png
0 件の賞賛
返信
3 返答(返信)

1,721件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @fengba_360 

Please find my answer in the form of software. This project configures EMIOS 0 CH0 as PWM and EMIOS 0 CH2 as SAIC for duty cycle measurement.

NOTE: The example code was developed using RTD version 4.0.0 P14 and the S32K3x4-T172EVB.

 

BR, VaneB

0 件の賞賛
返信

1,705件の閲覧回数
fengba_360
Contributor III

Thank you for your help. Currently, I am able to collect data, but I found that the duty cycle and period do not match my expectations. I input a PWM wave with 1KHZ and a duty cycle of 50% using the signal generator.

However, the collected data shows that ic_result_temp.PeriodTime = 54472, and ic_result_temp.ActiveTime = 1775.

According to the formula, the calculated duty cycle is 100*1775/54472=3%. And the frequency is Clock_Ip_GetClockFrequency(EMIOS0_CLK)/54472= 120MHZ/54472=2202HZ. Could you please take a look at it again?微信图片_20240924120202.png微信图片_20240924120056.jpg

0 件の賞賛
返信

1,683件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @fengba_360 

To the example code previous provided I have changed the configuration to measure a PWM of 1KHz with a duty cycle of 50% and resulting in a duty cycle of 49%.

0 件の賞賛
返信