// 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;
按照公式,不是应该是除法运算吗?为何这里先乘法运算,然后进行位与操作,再来一个位移操作。到底是怎么回事啊
求指导
此帖出自
小平头技术问答
一周热门 更多>