我现在手上有个电机(带有编码器)可以正常转动,我把它的qep的信号输出A、B信号外接出来,连接到dsp的eqep1A,eqep1B的引脚上面,然后运行 HVPM_Sensorless_2833x的pmsm的程序,但是qep的位置寄存器没有计数,qep程序没有启动,测不出机械转角和电气转角。下面是qep的程序,请
ti人解答一下
#define QEP_MACRO(m,v)
/* Check the rotational direction */
v.DirectionQep = (*eQEP[m]).QEPSTS.bit.QDF;
/* Check the position counter for EQEP1 */
v.RawTheta = (*eQEP[m]).QPOSCNT + v.CalibratedAngle;
if (v.RawTheta < 0)
v.RawTheta = v.RawTheta + (*eQEP[m]).QPOSMAX;
else if (v.RawTheta > (*eQEP[m]).QPOSMAX)
v.RawTheta = v.RawTheta - (*eQEP[m]).QPOSMAX;
/* Compute the mechanical angle */
v.MechTheta= v.MechScaler*v.RawTheta;
/* Compute the electrical angle */
v.ElecTheta = (v.PolePairs*v.MechTheta) -floor(v.PolePairs*v.MechTheta); /* Q24 = Q0*Q24 */
/* Check an index occurrence*/
if ((*eQEP[m]).QFLG.bit.IEL == 1)
[
v.IndexSyncFlag = 0x00F0;
v.QepCountIndex = (*eQEP[m]).QPOSILAT;
(*eQEP[m]).QCLR.bit.IEL = 1; /* Clear interrupt flag */
]
/* Check unit Time out-event for speed calculation: */
/* Unit Timer is configured for 100Hz in INIT function*/
if((*eQEP[m]).QFLG.bit.UTO == 1)
[
/***** Low Speed Calculation ****/
if(((*eQEP[m]).QEPSTS.bit.COEF || (*eQEP[m]).QEPSTS.bit.CDEF))
[ /* Capture Counter overflowed, direction change occurred ,hence do no compute speed*/
(*eQEP[m]).QEPSTS.all = 0x000C;
]
else if((*eQEP[m]).QCPRDLAT!=0xffff)
/* Compute lowspeed using capture counter value*/
v.QepPeriod = (*eQEP[m]).QCPRDLAT;
]
#endif // __F2833X_QEP_H__
0