您好,我是一名初学者,在学习eQEP模块关于电机位置和转速测量的官方示例文件时,不明白“eqep_ex2_calculation.c”文件中部分代码的作用,我迷惑代码段是:
//
temp = (int32_t)p->thetaRaw * (int32_t)p->mechScaler; // Q0 * Q26 = Q26
temp &= 0x03FFF000;
p->thetaMech = (int16_t)(temp >> 11); // Q26 -> Q15
p->thetaMech &= 0x7FFF;
//
// The following lines calculate p->elec_mech
//
p->thetaElec = p->polePairs * p->thetaMech; // Q0 * Q15 = Q15
p->thetaElec &= 0x7FFF;
//
我想询问:“temp &= 0x03FFF000;” 、 “p->thetaMech &= 0x7FFF;” 和 “p->thetaElec &= 0x7FFF;” 的作用分别是什么?
非常感谢您的帮助!