Interrupt-Driven ADC Sampling
12-20
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
Содержание MSC1210
Страница 1: ... December 2002 User s Guide SBAU077 ...
Страница 149: ...Digital Filter 12 13 Analog to Digital Converter Figure 12 5 Filter Frequency Responses ...
Страница 162: ...12 26 ...
Страница 234: ...Timers 17 6 Figure 17 4 Timer Counter 1 Mode 1 Figure 17 5 Interrupt System ...
Страница 273: ...Serial Port I O 17 45 Keil Simulator Figure 17 19 Clock Control Peripheral Figure 17 20 USART0 Preipheral ...
Страница 282: ...C 4 ...