2262011_zh-CN

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

2262011_zh-CN

2262011_zh-CN

如何使用 ICU 读取 PWM 数据?

我使用的是 S32K389 芯片。

我正在尝试使用 ICU 读取 PWM 输入数据,但没有成功。

如下图所示,PTF17 引脚被设置为 emios_1_ch_1_h 输入引脚。

jeff_choi_0662_1-1765706331768.png

然后,如下图所示,添加了一个元器件。

jeff_choi_0662_2-1765706395853.png

在 ICU 元器件中,ICUChannels、icuemiOS 和 ICUHWInterruptConfigList 设置为下图所示的值。

jeff_choi_0662_3-1765706488559.png

jeff_choi_0662_4-1765706648089.png

jeff_choi_0662_6-1765706700337.png

Mcl 元器件中的 emiosCommon 设置值的设置如下图所示。

jeff_choi_0662_7-1765706908117.png

IntCtrl 元器件的中断控制器设置值的设置如下图所示。

jeff_choi_0662_8-1765707016459.png

最后,对 Siul2_Port 元器件的 PortConfigSet 设置值进行了设置,如下图所示。

jeff_choi_0662_9-1765707114274.png

当我使用主函数中的 Emios_Icu_Ip_GetDutyCycleValues 函数读取 PWM 数据时,它不起作用。

下面的代码是经过测试的源代码。

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

#define INSTANCE_1(uint8)1U

#defineCHANNEL_0 (uint8)0U


eMios_Icu_Ip_DutyCycleTypeic_result_temp;


int main(void)

{

/* 初始化时钟 */

Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);


/* 使用 驱动程序驱动程序初始化所有引脚 */

Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_PortContainer_0_VS_0, g_pin_mux_InitConfigArr_PortContainer_0_VS_0);


/* 安装 EmiosISR */

IntCtrl_Ip_Init(&IntCtrlConfig_0);


/*Emios Mcl 启动*/

Emios_Mcl_Ip_Init(INSTANCE_1,&Emios_Mcl_Ip_Sa_1_Config_VS_0);


/* 初始化 Icu驱动程序 */

Emios_Icu_Ip_Init(INSTANCE_1,&eMios_Icu_Ip_1_Config_PB_VS_0);


/* 启动 eMIOS 通道的信号测量*/

Emios_Icu_Ip_StartSignalMeasurement(INSTANCE_1, CHANNEL_0);


同时(1)

{

Emios_Icu_Ip_GetDutyCycleValues(INSTANCE_1,CHANNEL_0,&ic_result_temp);


//如果被捕获

如果(ic_result_temp.PeriodTime)

{

/停止测量

Emios_Icu_Ip_StopSignalMeasurement(INSTANCE_1, CHANNEL_0);

打破;

}


delay();

}


Exit_Example(TRUE);

返回(0U);

}

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


Emios_Icu_Ip_GetDutyCycleValues 函数中的 EMIOS_ICU_DUTY_CYCLE 检查部分总是 EMIOS_ICU_NO_MEASUREMENT(eMios_Icu_Ip_axChState[eMios_Icu_Ip_u8IndexInChState[instance][hwChannel]].测量)。

jeff_choi_0662_10-1765707929776.png

谢谢!



Re: How can I read PWM data using ICU?

你好@jeff_choi_0662

我也遇到了类似的问题,如果您解决了测量频率的问题,能否分享一下配置或代码?

Tags (1)
No ratings
Version history
Last update:
‎01-12-2026 02:20 AM
Updated by: