2392112_zh-CN

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

2392112_zh-CN

2392112_zh-CN

S32K344 - EMIOS - IPM(输入周期测量)数据采集错误

您好,

我正在为我的 S32K3X4EVB-T172 评估板上的 EMIOS 模块编写裸机驱动程序。


目前,我使用的是配置好的 EMIOS_0,全局预分频器设置为 256 倍,通道配置如下:

CH_23 -> MC 递增计数器(Emios 计数器总线 A 的时基)@ 625 kHz

CH_17 -> 以 OPWMB 模式运行(使用计数器总线 A)

CH_22 -> MC 递增计数器(Emios 计数器总线 F 的时基)@ 156.25 kHz

CH_9 -> 以 IPM 模式运行(使用计数器总线 F)


我正在生成一个占空比为 50% 的 16.18Hz 信号,经示波器验证,我将其从 OPWMB 通道 ( PTA0) 路由到 IPWMB 通道 (PTA1)。

我每隔 10 毫秒采集一个 IPM 样本,它始终返回 9657/9658,因此我测得的周期为 9657 * 0.0000064 = 0.0618048,由此得出频率为 1/0.0618048 = 16.18Hz。

我遇到的问题是几乎周期性地获取错误值(如下所示)。

period[0] UINT16 40017
period[1] UINT16 9658
period[2] UINT16 9657
period[3] UINT16 9658
period[4] UINT16 40017
period[5] UINT16 9658
period[6] UINT16 9657
period[7] UINT16 9658
period[8] UINT16 40017
period[9] UINT16 9658
period[10] UINT16 9657
period[11] UINT16 40018
period[12] UINT16 9657
period[13] UINT16 9658
period[14] UINT16 9657
period[15] UINT16 40018

以下是一段代码片段,解释了我目前基于轮询的采集逻辑(不使用 DMA,也不使用中断):

如果(( EMIOS0 -> UC [ 9 ] . S & 1 u ) != 0 u )

{

UINT16 a1 = ( UINT16 ) EMIOS0 -> UC [ 9 ] . A ;

UINT16 b1 = ( UINT16 ) EMIOS0 -> UC [ 9 ] . B ;

UINT16 a2 = ( UINT16 ) EMIOS0 -> UC [ 9 ] 一个;

UINT16 b2 = ( UINT16 ) EMIOS0 -> UC [ 9 ] ;

如果( a1 != a2 )

{

如果( b1 != b2 )

{

period [ Index ] = ( UINT16 )( a2 - b2 ) ;

}

else

{

period [ Index ] = ( UINT16 )( a1 - b1 ) ;

}

}

else

{

period [ Index ] = ( UINT16 )( a2 - b2 ) ;

}

索引++;

如果索引> 99u

索引= 0 u ;

EMIOS0 -> UC [ 9 ] . S = EMIOS_UC_CLEAR_STATUS_FLG ; /* 80008001u */

}


测试不同频率时,异常值的出现频率大大降低,但仍然存在。以下是一个使用 303Hz 的例子:

period[0] UINT16 519
period[1] UINT16 519
period[2] UINT16 519
period[3] UINT16 519
period[4] UINT16 519
period[5] UINT16 519
period[6] UINT16 519
period[7] UINT16 519
period[8] UINT16 519
period[9] UINT16 519
period[10] UINT16 519
period[11] UINT16 519
period[12] UINT16 519
period[13] UINT16 30879
period[14] UINT16 519
period[15] UINT16 519
period[16] UINT16 519
period[17] UINT16 519
period[18] UINT16 519
period[19] UINT16 519
period[20] UINT16 519
period[21] UINT16 519
period[22] UINT16 519
period[23] UINT16 519
period[24] UINT16 519
period[25] UINT16 519
period[26] UINT16 519
period[27] UINT16 519
period[28] UINT16 519
period[29] UINT16 519
period[30] UINT16 519
period[31] UINT16 519
period[32] UINT16 519
period[33] UINT16 519
period[34] UINT16 519
period[35] UINT16 519
period[36] UINT16 519
period[37] UINT16 519
period[38] UINT16 519
period[39] UINT16 519
period[40] UINT16 519
period[41] UINT16 519
period[42] UINT16 519
period[43] UINT16 519
period[44] UINT16 519
period[45] UINT16 519
period[46] UINT16 519
period[47] UINT16 519
period[48] UINT16 519
period[49] UINT16 519
period[50] UINT16 519
period[51] UINT16 519
period[52] UINT16 519
period[53] UINT16 519
period[54] UINT16 519
period[55] UINT16 519
period[56] UINT16 519
period[57] UINT16 519
period[58] UINT16 30879
period[59] UINT16 519


有人能帮忙吗?

Re: S32K344 - EMIOS - IPM (Input Period Measurement) erroneous data acquisition

你好@fede_ls

你的轮询逻辑可能并非观察到的异常值的主要来源。这些数值强烈表明,周期计算没有正确处理所选计数器总线的翻转。当前表达式(uint16_t)(A - B)假设 16 位计数器在 65536 处完全翻转,但您的计数器总线 F 似乎在大约 35176 个时钟周期处翻转。因此,每当捕获的周期跨越计数器翻转时,都会添加65536 - 35176 = 30360刻度的额外偏移量,这与观察到的异常值完全匹配。
 
请检查 CH22 的周期/模数配置,该 CH22 用作 IPM 通道的计数器总线 F。周期应该使用实际的计数器总线模值来计算,而不是使用隐式的 16 位无符号减法。
 

顺祝商祺!

帕维尔

タグ(1)
評価なし
バージョン履歴
最終更新日:
‎07-09-2026 02:31 AM
更新者: