Lab 8: IQmath FIR Filter
C2000 Microcontroller Workshop - Numerical Concepts 8 - 37
IQTABLES with a TYPE = NOLOAD modifier after its allocation. The IQmath tables
are used by the IQmath library functions. The NOLOAD modifier allows the linker to
resolve all addresses in the section, but the section is not actually placed into the .out
file. This is done because the section is already present in the device ROM (you cannot
load data into ROM after the device is manufactured!). The tables were put in the ROM
by TI when the device was manufactured. All we need to do is link the section to the
addresses where it is known to already reside (the tables are the very first thing in the
BOOT ROM, starting at address 0x3F8000). Close the inspected file.
Select a Global IQ value
6. In the Project Explorer window under the Includes folder open:
C:\C28x\Labs\IQmath\include\IQmathLib.h. Confirm that the GLOBAL_Q
type (near beginning of file) is set to a value of 24. If it is not, modify as necessary:
#define GLOBAL_Q 24
Recall that this Q type will provide 8 integer bits and 24 fractional bits. Dynamic range
is therefore -128 < x < +128, which is sufficient for our purposes in the workshop.
Notice that the math type is defined as IQmath by:
#define MATH_TYPE IQ_MATH
Close the file.
IQmath Single-Sample FIR Filter
7. Open and inspect DefaultIsr_8.c. Notice that the ADCINT1_ISR calls the IQmath
single-sample FIR filter function, IQssfir(). The filter coefficients have been defined in
the beginning of Main_8.c. Also, as discussed in the lecture for this module, the ADC
results are read with the following instruction:
*AdcBufIQPtr = _IQmpy(ADC_FS_VOLTAGE,
_IQ12toIQ((_iq)AdcResult.ADCRESULT0));
The value of ADC_FS_VOLTAGE will be discussed in the next lab step.
8. Open and inspect Lab.h. Notice that, as discussed in the lecture for this module,
ADC_FS_VOLTAGE is defined as:
#if MATH_TYPE == IQ_MATH
#define ADC_FS_VOLTAGE _IQ(3.3)
#else // MATH_TYPE is FLOAT_MATH
#define ADC_FS_VOLTAGE _IQ(3.3/4096.0)
#endif
9. Open and inspect the IQssfir() function in Filter.c. This is a simple, non-optimized
coding of a basic IQmath single-sample FIR filter. Close the inspected files.
Build and Load
10. Click the “Build” button and watch the tools run in the Console window. Check for
errors in the Problems window.