TI中文支持网
TI专业的中文技术问题搜集分享网站

__qmpy32by16(long src32,int src16,int q);相关疑问,求解答

__qmpy32by16(long src32,int src16,int q)汇编源码如下:

long __qmpy32by16(long src32, int src16, int q);

                                      CLRC  OVM    ;Extended precision DSP Q math. Different code is generated based on the value of q.

                                      MOV  T, src16 + 0

                                      MPYXU  P, T, src32 + 0

                                      MPY  P, T, src32 + 1

If q = 31, 30:                SPM q − 30

                                      SFR ACC, #46 − q

                                      ADDL ACC, P

If q = 29 through 14:  SPM 0

                                      SFR ACC, #16

                                      ADDL ACC, P

                                      SFR ACC, #30 − q

If q = 13 through 0:    SPM 0

                                      SFR ACC, #16

                                      ADDL ACC, P

                                      SFR ACC, #16

                                      SFR ACC, #14 – q

这里有一个疑问,就是这一句MPYXU  P, T, src32 + 0,实际在CCS上看到的的汇编并不是P寄存器,而是ACC!相关的指令也对着指令集上的解释学习了,最后自己的理解是ACC=(ACC>>15)+(P<<1)  ;        这里ACC=src32*src16,      P=src16*(src32+1)  ;为什么要加1???

但是实际上这个内部定义函数的结果不应该是Q15=Q0*Q30<<(46-31)吗???

在eQEP源码中q=31

求解答,我的理解是不是错的????谢谢!

jay huang:

回复 jay huang:

补充QEP结构体变量的定义

typedef struct {

                          int32 ElecTheta;                                       // Output: Motor Electrical angle (Q24)                          int32 MechTheta;                                       // Output: Motor Mechanical Angle (Q24)                           Uint16 DirectionQep;                                 // Output: Motor rotation direction (Q0)                          Uint16 QepPeriod;                       // Output: Capture period of QEP signal in number of EQEP capture timer (QCTMR) period (Q0)                          Uint32 QepCountIndex;                // Variable: Encoder counter index (Q0)                           int32 RawTheta;                           // Variable: Raw angle from EQEP Postiion counter (Q0)                          Uint32 MechScaler;                    // Parameter: 0.9999/total count (Q30)                           Uint16 LineEncoder;                   // Parameter: Number of line encoder (Q0)                           Uint16 PolePairs;                        // Parameter: Number of pole pairs (Q0)                           int32 CalibratedAngle;                 // Parameter: Raw angular offset between encoder index and phase a (Q0)                          Uint16 IndexSyncFlag;                  // Output: Index sync status (Q0)                            void (*init)();                   // Pointer to the init function                            void (*calc)();                   // Pointer to the calc function                                                        } QEP;

赞(0)
未经允许不得转载:TI中文支持网 » __qmpy32by16(long src32,int src16,int q);相关疑问,求解答
分享到: 更多 (0)