ADC and Timers
In order to have a known sampling rate, the ADC must be interrupt driven. Set up your clock as usual, and let Timer B handle any filter clocks, if available. Set up the ADC to be interrupt driven and triggered by Timer A. Use the following code in order to set up Timer A:
/* TIMER A */
TACCR0 = 900;
TACCTL1 = OUTMOD_4;
TACTL |= TASSEL_2+MC_1;
DMA and DAC
Configure the DMA to transfer your filtered output sample to DAC0. You can set the DMA trigger inside the ADC12 interrupt service routine after you have finished the filtering.
Circular Buffer
Notice that FIR filter equation requires the N last input samples to compute the filtered output. In this case, you will need to store the last 21 samples including the most recent one. Implement a circular buffer to store all the required samples. Once you have reached the end of the buffer, reset your index back to zero.
Testing IO setup
Verify that the project is working so far by sending the newest value stored in your buffer to the DAC via DMA. Also, using the memory watch window, make sure that input samples are stored in their correct spot in the buffer. You may have to pause your program every time a sample is taken to verify that the buffer filling up correctly.










"Basic introduction to microcontroller-based embedded systems development. Includes structured laboratory exercises in the following areas: assembly programming, C language programming, peripheral […]"
"This lab shows you how to set up an FIR filter on the MSP430"