|
本帖最后由 ln08136207 于 2014-3-12 16:21 编辑
在ke02_bldc_demo 2.0程序中,有下面一段程序:
switch (value)
{
case 5: /* -->BA */
FTM2_OUTMASK = 0x30; /* mask pwm4, pwm5 */
FTM2_SWOCTRL = 0x0203; /* pwm0 output 0, pwm1 output 1 */
Q2_TOP_B_PWM (0); /* pwm2 and pwm3 complement output */
Q5_BOTTOM_B_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 1: /* -->CA */
FTM2_OUTMASK = 0x0C; /* mask pwm2, pwm3 */
FTM2_SWOCTRL = 0x0203; /* pwm0 output 0, pwm1 output 1 */
Q3_TOP_C_PWM (0); /* pwm4 and pwm5 complement output */
Q6_BOTTOM_C_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 3: /* -->CB */
FTM2_OUTMASK = 0x03; /* mask pwm0, pwm1 */
FTM2_SWOCTRL = 0x080C; /* pwm2 output 0, pwm3 output 1 */
Q3_TOP_C_PWM (0); /* pwm4 and pwm5 complement output */
Q6_BOTTOM_C_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 2: /* -->AB */
FTM2_OUTMASK = 0x30; /* mask pwm4, pwm5 */
FTM2_SWOCTRL = 0x080C; /* pwm2 output 0, pwm3 output 1 */
Q1_TOP_A_PWM (0); /* pwm0 and pwm1 complement output */
Q4_BOTTOM_A_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 6: /* -->AC */
FTM2_OUTMASK = 0x0C; /* mask pwm2, pwm3 */
FTM2_SWOCTRL = 0x2030; /* pwm4 output 0, pwm5 output 1 */
Q1_TOP_A_PWM (0); /* pwm0 and pwm1 complement output */
Q4_BOTTOM_A_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
case 4: /* -->BC */
FTM2_OUTMASK = 0x03; /* mask pwm0, pwm1 */
FTM2_SWOCTRL = 0x2030; /* pwm4 output 0, pwm5 output 1 */
Q2_TOP_B_PWM (0); /* pwm0 and pwm1 complement output */
Q5_BOTTOM_B_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */
break;
default:
break;
}
以case 5 为例:
首先禁止PWM4 PWM5的输出,
其次是将 PWM0,PWM1改为软件控制,且PWM0输出0,PWM1输出1
然后使PWM2和PWM3互补输出,PWM2输出1,PWM3输出0
最后,黑体部分Q5_BOTTOM_B_PWM (pwm_value); /* channel n =0 and channel n+1 = pwm value */ ,这句的作用是什么?使PWM3 = 0,PWM4输出pwm_value? 这样的话不是打开->CA吗?
还是我理解有误?
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|