EasyManuals Logo

Texas Instruments C28 Series Student Guide

Texas Instruments C28 Series
342 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #191 background imageLoading...
Page #191 background image
Converting ADC Results into IQ Format
Converting ADC Results into IQ Format
As you may recall, the converted values of the ADC are placed in the upper 12 bit of the
RESULT0 register. Before these values are filtered using the IQmath library, they need to to be
put into the IQ format as a 32-bit long.
Getting the ADC Result into IQ Format
Getting the ADC Result into IQ Format
RESULTx
RESULTx
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
0
0
0
0
0
0
0
0x
x
x
x
32
32
-
-
bit long
bit long
15
15
0
0
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
x
x
x
x
31
31
0
0
0
0
0
0
0
0
Do not sign extend
Do not sign extend
Notice that the 32
Notice that the 32
-
-
bit long is already in IQ16 format!
bit long is already in IQ16 format!
#define
#define
AdcFsVoltage
AdcFsVoltage
IQ(3.0) // ADC full scale voltage
IQ(3.0) // ADC full scale voltage
_
_
iq
iq
Result, temp; // ADC result
Result, temp; // ADC result
void main(void)
void main(void)
{
{
// convert the unsigned 16
// convert the unsigned 16
-
-
bit result to unsigned 32
bit result to unsigned 32
-
-
bit
bit
temp =
temp =
AdcRegs
AdcRegs
.ADCRESULT0;
.ADCRESULT0;
// convert resulting IQ16 to IQ format
// convert resulting IQ16 to IQ format
temp = _IQ16toIQ(temp);
temp = _IQ16toIQ(temp);
// scale by ADC full
// scale by ADC full
-
-
scale range (optional)
scale range (optional)
Result = _
Result = _
IQmpy
IQmpy
(
(
AdcFsVoltage
AdcFsVoltage
, temp);
, temp);
}
}
Result = _
Result = _
IQmpy
IQmpy
(
(
AdcFsVoltage
AdcFsVoltage
, _IQ16toIQ( (_
, _IQ16toIQ( (_
iq
iq
)
)
AdcRegs
AdcRegs
.ADCRESULT0));
.ADCRESULT0));
For uni-polar ADC inputs (i.e., 0 to 3 V inputs), a conversion to global IQ format can be achieved
with:
IQresult_unipolar = _IQmpy(_IQ(3.0),_IQ16toIQ((_iq) AdcRegs.ADCRESULT0));
How can we modify the above to recover bi-polar inputs, for example +-1.5 volts? One could do
the following to offset the +1.5V analog biasing applied to the ADC input:
IQresult_bipolar =
_IQmpy(_IQ(3.0),_IQ16toIQ((_iq) AdcRegs.ADCRESULT0)) - _IQ(1.5);
However, one can see that the largest intermediate value the equation above could reach is 3.0.
This means that it cannot be used with an IQ data type of IQ30 (IQ30 range is -2 < x < ~2). Since
the IQmath library supports IQ types from IQ1 to IQ30, this could be an issue in some applica-
tions.
The following clever approach supports IQ types from IQ1 to IQ30:
IQresult_bipolar =
_IQmpy(_IQ(1.5),_IQ15toIQ((_iq) ((int16) (AdcRegs.ADCRESULT0 ^ 0x8000))));
The largest intermediate value that this equation could reach is 1.5. Therefore, IQ30 is easily
supported.
C28x - Numerical Concepts & IQmath 8 - 35

Table of Contents

Other manuals for Texas Instruments C28 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments C28 Series and is the answer not in the manual?

Texas Instruments C28 Series Specifications

General IconGeneral
BrandTexas Instruments
ModelC28 Series
CategoryComputer Hardware
LanguageEnglish

Related product manuals