下面一段程序的功能是检测同步机转子位置,不知思路是什么?
void SynInitPosDetSetPwm(Uint Section)
{
EALLOW;
switch(Section)
{
case 0: // A+, B-
EPwm1Regs.AQCSFRC.all = 0x08;
EPwm2Regs.AQCSFRC.all = 0x02;
EPwm3Regs.AQCSFRC.all = 0x0A; //1010?
break;
case 1: // A-, B+
EPwm1Regs.AQCSFRC.all = 0x02;
EPwm2Regs.AQCSFRC.all = 0x08;
EPwm3Regs.AQCSFRC.all = 0x0A;
break;
case 2: // B+, C-
EPwm1Regs.AQCSFRC.all = 0x0A;
EPwm2Regs.AQCSFRC.all = 0x08;
EPwm3Regs.AQCSFRC.all = 0x02;
break;
case 3: // B-, C+
EPwm1Regs.AQCSFRC.all = 0x0A;
EPwm2Regs.AQCSFRC.all = 0x02;
EPwm3Regs.AQCSFRC.all = 0x08;
break;
case 4: // A-, C+
EPwm1Regs.AQCSFRC.all = 0x02;
EPwm2Regs.AQCSFRC.all = 0x0A;
EPwm3Regs.AQCSFRC.all = 0x08;
break;
case 5: // A+, C-
EPwm1Regs.AQCSFRC.all = 0x08;
EPwm2Regs.AQCSFRC.all = 0x0A;
EPwm3Regs.AQCSFRC.all = 0x02;
break;
case 6: //恢复PWM模块的寄存器设置
EPwm1Regs.DBCTL.all = 0x0007; //OUT_MODE=11 POLSEL=01
EPwm1Regs.AQCTLA.all = 0x0090; //CAD=10 下降计数若比较相等,则Set: force EPWMxA output high;CAU=01 上升计数若比较相等,Clear: force EPWMxA output low
EPwm1Regs.AQCTLB.all = 0x00;
EPwm1Regs.AQCSFRC.all = 0x00;
EPwm2Regs.DBCTL.all = 0x0007;
EPwm2Regs.AQCTLA.all = 0x0090;
EPwm2Regs.AQCTLB.all = 0x00;
EPwm2Regs.AQCSFRC.all = 0x00;
EPwm3Regs.DBCTL.all = 0x0007;
EPwm3Regs.AQCTLA.all = 0x0090;
EPwm3Regs.AQCTLB.all = 0x00;
EPwm3Regs.AQCSFRC.all = 0x00;
break;
default: //同步机初始位置角检测初始化寄存器
EPwm1Regs.AQCSFRC.all = 0x0A; //CSFB=2--EPWM1B=1 CSFA=2--EPWM1A=1
EPwm1Regs.DBCTL.all = 0;
EPwm1Regs.AQCTLA.all = 0x000C; //PRD---Toggle EPWM1A
EPwm1Regs.AQCTLB.all = 0x000C; //PRD---Toggle EPWM1B
EPwm2Regs.AQCSFRC.all = 0x0A;
EPwm2Regs.DBCTL.all = 0;
EPwm2Regs.AQCTLA.all = 0x000C;
EPwm2Regs.AQCTLB.all = 0x000C;
EPwm3Regs.AQCSFRC.all = 0x0A;
EPwm3Regs.DBCTL.all = 0;
EPwm3Regs.AQCTLA.all = 0x000C;
EPwm3Regs.AQCTLB.all = 0x000C;
break;
}
EDIS;
}
|