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
0
x
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 e-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
Содержание C28 Series
Страница 64: ...Summary 3 16 C28x Peripheral Registers Header Files ...
Страница 78: ...Interrupt Sources 4 14 C28x Reset and Interrupts ...
Страница 218: ...Lab 9 DSP BIOS 9 22 C28x Using DSP BIOS ...
Страница 244: ...Lab 10 Programming the Flash 10 26 C28x System Design ...
Страница 273: ...Appendix A eZdsp F2812 C28x Appendix A eZdsp F2812 A 1 ...
Страница 275: ...Appendix eZdsp F2812 eZdsp F2812 Connector Header and Pin Diagram C28x Appendix A eZdsp F2812 A 3 ...
Страница 276: ...Appendix P2 Expansion Interface A 4 C28x Appendix A eZdsp F2812 ...
Страница 277: ...Appendix P4 P8 P7 I O Interface C28x Appendix A eZdsp F2812 A 5 ...
Страница 278: ...Appendix A 6 C28x Appendix A eZdsp F2812 ...
Страница 279: ...Appendix P5 P9 Analog Interface C28x Appendix A eZdsp F2812 A 7 ...
Страница 281: ...Appendix JP7 JP8 JP11 JP12 Boot Mode Select JP9 PLL Disable DS1 DS2 LEDs C28x Appendix A eZdsp F2812 A 9 ...
Страница 282: ...Appendix A 10 C28x Appendix A eZdsp F2812 TP1 TP2 Test Points ...