This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

感应电机控制中GPIO口设置的问题



我在电机控制的程序中使能普通I/O口,可是在置高置低的过程中,波形始终不对,不是正常的高低电平的方波信号,不知道为什么,下面是一段程序(六步换向程序)

// 0<=Angle<1/6  to voltage base vector 1 U_BASE_1
 if ( (0 <= rg1.Out) && ( rg1.Out < _IQ(0.1666667) ) )
 {Num = 1;
    GpioDataRegs.GPADAT.bit.GPIO7 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO6 = 1;  \
    GpioDataRegs.GPADAT.bit.GPIO9 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO8 = 1;  \
    GpioDataRegs.GPADAT.bit.GPIO10 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO11 = 1;
 }
 // 1/6<=Angle<1/3  to voltage base vector 2 U_BASE_2
 else if ( (_IQ(0.1666667) <= rg1.Out) && ( rg1.Out < _IQ(0.3333333) ) )
 {Num = 2;
    GpioDataRegs.GPADAT.bit.GPIO6 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO7= 1;  \
    GpioDataRegs.GPADAT.bit.GPIO9 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO8 = 1;  \
    GpioDataRegs.GPADAT.bit.GPIO10 = 0; \
    GpioDataRegs.GPADAT.bit.GPIO11 = 1;
 }
 // 1/3<=Angle<1/2  to voltage base vector 3 U_BASE_3
 else if ( (_IQ(0.3333333) <= rg1.Out) && ( rg1.Out < _IQ(0.5) ) )
 {Num = 3;
    GpioDataRegs.GPADAT.bit.GPIO6 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO7= 1;  \
    GpioDataRegs.GPADAT.bit.GPIO9 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO8 = 1;  \
    GpioDataRegs.GPADAT.bit.GPIO11 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO10 = 1;
 }
 // 0<=Angle<1/6  to voltage base vector 1 U_BASE_1
 else if ( (_IQ(0.5) <= rg1.Out) && ( rg1.Out < _IQ(0.6666667) ) )
 {Num = 4;
    GpioDataRegs.GPADAT.bit.GPIO6 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO7= 1; \
    GpioDataRegs.GPADAT.bit.GPIO8 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO9 = 1; \
    GpioDataRegs.GPADAT.bit.GPIO11 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO10 = 1;
 }
 // 0<=Angle<1/6  to voltage base vector 1 U_BASE_1
 else if ( (_IQ(0.6666667) <= rg1.Out) && ( rg1.Out < _IQ(0.8333333) ) )
 {Num = 5;
    GpioDataRegs.GPADAT.bit.GPIO7 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO6 = 1; \
    GpioDataRegs.GPADAT.bit.GPIO8 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO9 = 1; \
    GpioDataRegs.GPADAT.bit.GPIO11 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO10 = 1;
 }
 // 0<=Angle<1/6  to voltage base vector 1 U_BASE_1
 else if ( (_IQ(0.8333333) <= rg1.Out) && ( rg1.Out < _IQ(1) ) )
 {Num = 6;
    GpioDataRegs.GPADAT.bit.GPIO7 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO6 = 1; \
    GpioDataRegs.GPADAT.bit.GPIO8 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO9 = 1; \
    GpioDataRegs.GPADAT.bit.GPIO10 = 0; \
     GpioDataRegs.GPADAT.bit.GPIO11 = 1;
 }
 else
 {Num = 0;
 GpioDataRegs.GPADAT.bit.GPIO6 = 0; \
 GpioDataRegs.GPADAT.bit.GPIO7= 1; \
 GpioDataRegs.GPADAT.bit.GPIO8 = 0; \
 GpioDataRegs.GPADAT.bit.GPIO9 = 1; \
 GpioDataRegs.GPADAT.bit.GPIO10 = 0; \
 GpioDataRegs.GPADAT.bit.GPIO11 = 1;
 }