How can I read PWM data using ICU?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I read PWM data using ICU?

327 Views
jeff_choi_0662
Contributor I

I'm using the S32K389 chip.

I'm trying to read PWM input data using the ICU, but it's not working.

As shown in the figure below, the PTF17 pin is set to the emios_1_ch_1_h input pin.

jeff_choi_0662_1-1765706331768.png

And then, as shown in the figure below, a component was added.

jeff_choi_0662_2-1765706395853.png

In the ICU component, IcuChannels, IcueMios, and IcuHwInterruptConfigList are set to the values ​​shown in the figure below.

jeff_choi_0662_3-1765706488559.png

jeff_choi_0662_4-1765706648089.png

jeff_choi_0662_6-1765706700337.png

The EmiosCommon setting value in the Mcl component is set as shown in the figure below.

jeff_choi_0662_7-1765706908117.png

The Interrupt Controller setting value for the IntCtrl component is set as shown in the figure below.

jeff_choi_0662_8-1765707016459.png

Finally, the PortConfigSet setting value for the Siul2_Port component was set as shown in the figure below.

jeff_choi_0662_9-1765707114274.png

When I read PWM data using the Emios_Icu_Ip_GetDutyCycleValues ​​function in the main function, it is not working.

The code below is the source code that was tested.

====================================================================

#define INSTANCE_1 (uint8)1U

#define CHANNEL_0 (uint8)0U

 

eMios_Icu_Ip_DutyCycleType ic_result_temp;

 

int main(void)

{

/* Initialize clock */

Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);

 

/* Initialize all pins using the Acu driver */

Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_VS_0, g_pin_mux_InitConfigArr_PortContainer_0_VS_0);

 

/* Install Emios ISR */

IntCtrl_Ip_Init(&IntCtrlConfig_0);

 

/*Emios Mcl Init */

Emios_Mcl_Ip_Init(INSTANCE_1, &Emios_Mcl_Ip_Sa_1_Config_VS_0);

 

/* Initialize the Icu driver */

Emios_Icu_Ip_Init(INSTANCE_1, &eMios_Icu_Ip_1_Config_PB_VS_0);

 

/* Starts the signal measurement of eMIOS channel*/

Emios_Icu_Ip_StartSignalMeasurement(INSTANCE_1, CHANNEL_0);

 

while(1)

{

Emios_Icu_Ip_GetDutyCycleValues(INSTANCE_1, CHANNEL_0, &ic_result_temp);

 

//If captured

if(ic_result_temp.PeriodTime)

{

//Stop measuring

Emios_Icu_Ip_StopSignalMeasurement(INSTANCE_1, CHANNEL_0);

break;

}

 

delay();

}

 

Exit_Example(TRUE);

return (0U);

}

====================================================================

 

The EMIOS_ICU_DUTY_CYCLE check part in the Emios_Icu_Ip_GetDutyCycleValues ​​function is always EMIOS_ICU_NO_MEASUREMENT(eMios_Icu_Ip_axChState[eMios_Icu_Ip_u8IndexInChState[instance][hwChannel]].measurement).

jeff_choi_0662_10-1765707929776.png

 

Thank you.

 

 

0 Kudos
Reply
1 Reply

156 Views
gayancho
Contributor II

Hi @jeff_choi_0662 

 I'm also facing similar problems if you resolve this issue for measuring the frequency can you share the configuration or code?

0 Kudos
Reply