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.

PMSM3_3 ADC transformation value query.

Hi All,

I'm trying to understand the ADC section in the pmsm3_3 code from TI. I've asked suport for help, but I'm hoping for a faster response.

In the driver library project(F280xDRV_ml) in the F280xadc04b.adc for bipolar signals, the following transformation is done in the read() function:

        DatQ15 = AdcRegs.ADCRESULT0^0x8000;      // Convert raw result to Q15 (bipolar signal)
        Tmp = (int32)p->Ch1Gain*(int32)DatQ15;  // Tmp = gain*dat => Q28 = Q13*Q15
        p->Ch1Out = (int16)(Tmp>>13);           // Convert Q28 to Q15
        p->Ch1Out += p->Ch1Offset;              // Add offset

 

The XOR is to get a bipolar(+ve/-ve) signal. The gain is multiplied and right shifted by the number of gain places. An offset is then added. This value is then used by the algorithm which seems to work ok.

What I'm unable to understand is why the adc is never right shifted by four places( since RAW adc values are stored in the upper section of the 16 bit register). The algorightm never right shifts it.  Any light on this will be appreciated. Thanks!