EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 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 #195 background imageLoading...
Page #195 background image
195
The block size indicates that number of locations that we will need to store ADC10 data. MSP430s are
16-bit microcontrollers and since ADC10 gives 10-bit data, we need sixteen word-sized (16-bit)
locations to store sixteen ADC samples. These 16 samples are to be averaged.
#define no_of_samples 16
....
unsigned int adc_pointer[no_of_samples];
....
....
ADC10DTC1 = no_of_samples;
ADC10SA = ((unsigned int)adc_pointer);
Grace generates the initialization code but the above lines must be edited by the coder.
In the main function, ADC10 is commanded to begin and store conversions. Once all sixteen ADC10
data are captured, they are summed up and averaged. The averaged data is shown on a LCD screen.
Note that ADC10 interrupt is not used and not anywhere in the code the ADC10MEM register is
directly read. The ADC is read and processed by the DMA, freeing up the CPU for other tasks. The
process is repetitive, automomous and continuous.
adc_avg = 0;
P1OUT |= BIT0;
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY);
ADC10CTL0 |= (ENC | ADC10SC);
for(s = 0; s < no_of_samples; s++)
{
adc_avg += adc_pointer[s];
}
adc_avg = (adc_avg / no_of_samples);
lcd_print(12, 1, adc_avg);
delay_ms(100);
P1OUT &= ~BIT0;
delay_ms(100);

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

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

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals