用相同的配置,分析设置 TIMER42 PA4 TIM4_2_OWH
PA5 TIM4_2_OWL
PC4 TIM4_2_OUH
PC5 TIM4_2_OUL
/* Set OCO compare value */
TIMER4_OCO_WriteOccr(TIMER4_UNIT, TIMER4_OCOU_HIGH_CH, u8OcoOccrVal);
TIMER4_OCO_WriteOccr(TIMER4_UNIT, TIMER4_OCOU_LOW_CH, u8OcoOccrVal/2);
TIMER4_OCO_WriteOccr(TIMER4_UNIT, TIMER4_OCOW_HIGH_CH, u8OcoOccrVal);
TIMER4_OCO_WriteOccr(TIMER4_UNIT, TIMER4_OCOW_LOW_CH, u8OcoOccrVal/4);
/* Enable OCO */
TIMER4_OCO_OutputCompareCmd(TIMER4_UNIT, TIMER4_OCOU_HIGH_CH, Enable);
TIMER4_OCO_OutputCompareCmd(TIMER4_UNIT, TIMER4_OCOU_LOW_CH, Enable);
TIMER4_OCO_OutputCompareCmd(TIMER4_UNIT, TIMER4_OCOW_HIGH_CH, Enable);
TIMER4_OCO_OutputCompareCmd(TIMER4_UNIT, TIMER4_OCOW_LOW_CH, Enable);
/* Initialize PWM I/O */
PORT_SetFunc(TIMER4_PWMU_H_PORT, TIMER4_PWMU_H_PIN, Func_Tim4, Disable);
PORT_SetFunc(TIMER4_PWMU_L_PORT, TIMER4_PWMU_L_PIN, Func_Tim4, Disable);
PORT_SetFunc(TIMER4_PWMW_H_PORT, TIMER4_PWMW_H_PIN, Func_Tim4, Disable);
PORT_SetFunc(TIMER4_PWMW_L_PORT, TIMER4_PWMW_L_PIN, Func_Tim4, Disable);
/* Timer4 PWM: Initialize PWM configuration structure */
stcPwmInit.enRtIntMaskCmd = Enable;
stcPwmInit.enClkDiv = PwmPlckDiv1;
stcPwmInit.enOutputState = PwmHHoldPwmLReverse;
stcPwmInit.enMode = PwmThroughMode;
TIMER4_PWM_Init(TIMER4_UNIT, TIMER4_PWMU_CH, &stcPwmInit); /* Initialize timer4 pwm */
TIMER4_PWM_Init(TIMER4_UNIT, TIMER4_PWMW_CH, &stcPwmInit); /* Initialize timer4 pwm */
希望生成 两组互补的PWM输出。
结果 W 通道有互补的输出,U通道输出是没有互补的。不知道哪里设置有问题?
|