AnuHV
Member level 2
Code:
#include <msp430x44x.h>
// These need to be global in this example. Otherwise, the
// compiler removes them because they are not used
static unsigned int A0results;
static unsigned int A5results;
static unsigned int A2results;
static unsigned int A3results;
static unsigned int A4results;
int ADC();
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
ADC();
}
ADC()
{
P6SEL=0x3D;
P5SEL=0X00;
P5DIR=0XFF;// Enable A/D channel inputs
ADC12CTL0 = ADC12ON+MSC+SHT0_8; // ADC12 on, extend sampling time
// to avoid overflow of results
ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated seq
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2
ADC12MCTL3 = INCH_3; //ref+=AVcc, channel = A3
ADC12MCTL4 = INCH_4;
ADC12MCTL5 = INCH_5+EOS;// ref+=AVcc, channel = A4, end seq.
ADC12IE = 0x08; // Enable ADC12IFG.3
ADC12CTL0 |= ENC; // Enable conversions
ADC12CTL0 |= ADC12SC; // Start conversion
_BIS_SR(LPM0_bits+GIE); // Enter LPM0, enable interrupts
}
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
//static unsigned int index = 0;
A0results = ADC12MEM0; // Move A0 results, IFG is cleared
A2results = ADC12MEM2; // Move A2 results, IFG is cleared
A3results = ADC12MEM3; // Move A3 results, IFG is cleared
A4results = ADC12MEM4; // Move A4 results, IFG is cleared
A5results = ADC12MEM5;
If((0x0A00<=A0results<=0x0Aff)&&(0x0A00<=A2results<=0x0B50)&&(0x0A00<=A3results<=0x0BFF)&&(0x0850<=A4results<=0x09FF)&&(0x0C00<=A5results<=0x0CFF))
P5OUT=0XFF;
else
P5OUT=0X00;
}
could someone rectify my mistake please?