void BLDCtable(u8 aa)
{
if(aa)
{
switch(BLDC.BLCD_tab)
{
case 5://T1 T4 导通 中间+了IR2108逻辑转换 这里面的时序最终是T1 T4导通
BLCD_WT2_Set;// T2 PB2
BLCD_WT4_Reset;// T4 PB10
BLCD_WT6_Set;// T6 PB0
TIM_ForcedOC1Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare1(TIM3,BLDC.pwm);//BLDC.pwm T1 TIM3_CH1 PB4
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);// InActive输出的是1 和手册相反 Active输出0 硬件光耦逻辑反 新版取消了逻辑反
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 4: //T1 T6
BLCD_WT2_Set;
BLCD_WT4_Set;
BLCD_WT6_Reset;//
TIM_ForcedOC1Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare1(TIM3,BLDC.pwm);//BLDC.pwm T1 TIM3_CH1 PB4
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 6: //T3 T6
BLCD_WT2_Set;
BLCD_WT4_Set;
BLCD_WT6_Reset;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);//
TIM_ForcedOC2Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare2(TIM3,BLDC.pwm);//
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 2://T3 T2
BLCD_WT2_Reset;
BLCD_WT4_Set;
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);//
TIM_ForcedOC2Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare2(TIM3,BLDC.pwm);//
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 3: //T5 T2
BLCD_WT2_Reset;
BLCD_WT4_Set;
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare4(TIM3,BLDC.pwm);
compute_speed();
break;
case 1: //T5 T4
BLCD_WT2_Set;
BLCD_WT4_Reset;//
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare4(TIM3,BLDC.pwm);
compute_speed();
break;
default:
// BLCD_WT2_Reset;
// BLCD_WT4_Reset;
// BLCD_WT6_Reset;
// TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_InActive);
// TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_InActive);
// TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_InActive);
break;
}//switch
}
else
{
switch(BLDC.BLCD_tab)
{
case 5://T3 T2
BLCD_WT2_Reset;
BLCD_WT4_Set;
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);//
TIM_ForcedOC2Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare2(TIM3,BLDC.pwm);//
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 4: //T5 T2
BLCD_WT2_Reset;
BLCD_WT4_Set;
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare4(TIM3,BLDC.pwm);
compute_speed();
break;
case 6: //T5 T4
BLCD_WT2_Set;
BLCD_WT4_Reset;//
BLCD_WT6_Set;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare4(TIM3,BLDC.pwm);
compute_speed();
break;
case 2://T1 T4
BLCD_WT2_Set;// T2 PB2
BLCD_WT4_Reset;// T4 PB10
BLCD_WT6_Set;// T6 PB0
TIM_ForcedOC1Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare1(TIM3,BLDC.pwm);//BLDC.pwm T1 TIM3_CH1 PB4
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);// InActive输出的是1 和手册相反 Active输出0
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 3: //T1 T6
BLCD_WT2_Set;
BLCD_WT4_Set;
BLCD_WT6_Reset;//
TIM_ForcedOC1Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare1(TIM3,BLDC.pwm);//BLDC.pwm T1 TIM3_CH1 PB4
TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_Active);
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
case 1: //T3 T6
BLCD_WT2_Set;
BLCD_WT4_Set;
BLCD_WT6_Reset;
TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_Active);//
TIM_ForcedOC2Config(TIM3,TIM_OCMode_PWM1);TIM_SetCompare2(TIM3,BLDC.pwm);//
TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_Active);
compute_speed();
break;
default:
// BLCD_WT2_Reset;
// BLCD_WT4_Reset;
// BLCD_WT6_Reset;
// TIM_ForcedOC1Config(TIM3,TIM_ForcedAction_InActive);
// TIM_ForcedOC2Config(TIM3,TIM_ForcedAction_InActive);
// TIM_ForcedOC4Config(TIM3,TIM_ForcedAction_InActive);
break;
}//switch
}
} |