Interrupt-Driven ADC Sampling

12.14 Interrupt-Driven ADC Sampling

A useful, power-saving technique for obtaining ADC samples includes using the power-down mode of the MSC1210 between the time that a sample is re- quested and the time that a sample is made available to the MCU. During this time, the MSC1210 may be put into power-down mode by setting PCON.1 (PD). This will reduce power consumption significantly while the ADC sample is acquired.

The power−down mode is exited when the ADC unit triggers an interrupt. This interrupt will take the MCU out of power-down mode, execute the appropriate interrupt, and then continue with program execution.

#include <REG1210.H> #include <stdio.h> #include <stdlib.h> #include <math.h>

#define LSB 298.0232e−9 /* LSB=5.0/2^24 */ extern void autobaud(void);

extern long bipolar(void);

long sample; // Hold the samples retrieved from A/D converter void auxiliary_isr( void) interrupt 6 //AuxInt

{

sample = bipolar() * LSB; // Read sample & clear ADCIRQ AI=CLEAR; // Clear Aux Int right before Aux ISR exit

}

void main(void)

{

float volts, temp, resistance, ratio, lr, ave; int i, k, decimation = 1728, samples;

CKCON = 0; // 0 MOVX cycle stretch autobaud();

printf(”MSC1210 Interrupt−Driven ADC Conversion Test\n”); //Timer Setup

USEC= 10; // 11MHz Clock

ACLK = 9; // ACLK = 11,0592,000/10 = 1,105,920 Hz

//modclock = 1,105,920/64 = 17,280 Hz

//Setup interrupts

EAI = 1; // Enable auxiliary interrupts AIE = 0x20; // Enable A/D aux. interrupt // Setup ADC

PDCON &= 0x0f7; //turn on adc

ADMUX = 0x01; //Select AIN0/AIN1

ADCON0 = 0x30; // Vref On, Vref Hi, Buff off, BOD off, PGA=1

12-20

Page 156
Image 156
Texas Instruments MSC1210 manual Interrupt-Driven ADC Sampling