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.

TMS320F28069: 28069QEP例程理解

Part Number: TMS320F28069


p->DirectionQep = EQep1Regs.QEPSTS.bit.QDF; //电机旋转方向 Motor direction: 0=CCW/reverse, 1=CW/forward

pos16bval=(unsigned int)EQep1Regs.QPOSCNT; // capture position once per QA/QB period 每个QA周期计数值
p->theta_raw = pos16bval+ p->cal_angle; // raw theta = current pos. + ang. offset from QA角度=计数值+原始偏差

// The following lines calculate p->theta_mech ~= QPOSCNT/mech_scaler [current cnt/(total cnt in 1 rev.)]
// where mech_scaler = 4000 cnts/revolution
tmp = (long)((long)p->theta_raw*(long)p->mech_scaler); // Q0*Q26 = Q26
tmp &= 0x03FFF000;
p->theta_mech = (int)(tmp>>11); // Q26 -> Q15
p->theta_mech &= 0x7FFF;

这段什么意思呀 特别是那些左移右移程序