IcuGeneral-勾選IcuDevErrorDetect
IcuOptionalApis-勾選ICU-edge detect/signal measurement相關的API
IcuConfigSet-配置ICU channel
其中一路是用於PWM捕獲(無需額外配置中斷)
IcuChannel_FAN1_TACH,
硬件觸發單元選擇-GTM(ICU一般都是由定時器來實現)
IcuDefaultStartEdge-Rising Edge(三種觸發沿模式,下降沿/上升沿/雙邊沿)
IcuMeasurementMode-Signal measurement(五種測量模式,邊沿計數/信號邊沿捕獲/信號測量/時間戳測量/周期信號時間測量)
在channel下新增signal measurement配置項
IcuSignalMeasurement
IcuSignalMeasurementProperty選擇duty cycle
在channel下新增GtmTimerInputConfiguration配置項
GtmTimerInputConfiguration,與MCUGTMTIM中配置爲ICU的通道進行Mapping
TimChannelFilterConfig
TimChannelGeneral
TimChannelPortPinSelect:選擇對應PORT引脚
TimInterruptMode:選擇interrupt pulse notify
另一路是用於邊沿捕獲(需額外配置中斷,timestamp mode也要配)
Channel下新建edge detect配置項
配置notify函數
Channel下新建GtmTimerInputConfiguration配置項
Mapping Tim channel
TimChannelFilterConfig
TimChannelGeneral
在OS中配置ISR
ISR Interrupt Source計算公式如下:(以TC397為例)
PWM配置
PwmGeneral
PwmConfigurationOfOptApiServices
PwmChannelConfigSet
新建PWM channel
CCU6CC6Configuration
GtmTimerOutputModuleConfiguration -不分频clock0
在代碼中配置ISR
使能ICU 功能
周期獲取PWM周期和占空比信息