AnuHV
Member level 2
Hi,
i wrote a program for ADC for five channels.it worked properly but after somedays when i tried the same it not entering the ISR
its urgent please could someone help me?
in the analog input pins where the sensor is connected i am getting the voltage values but not entering ISR
i wrote a program for ADC for five channels.it worked properly but after somedays when i tried the same it not entering the ISR
Code:
#include <msp430x44x.h>
#define Num_of_Results 8
// These need to be global in this example. Otherwise, the
// compiler removes them because they are not used
static unsigned int A0results[Num_of_Results];
static unsigned int A5results[Num_of_Results];
static unsigned int A2results[Num_of_Results];
static unsigned int A3results[Num_of_Results];
static unsigned int A4results[Num_of_Results];
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
// ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1
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[index] = ADC12MEM0; // Move A0 results, IFG is cleared
// A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared
A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared
A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared
A4results[index] = ADC12MEM4; // Move A4 results, IFG is cleared
A5results[index] = ADC12MEM5;
index = (index+1);//%Num_of_Results; // Increment results index, modulo
// _NOP();
// SET BREAKPOINT HERE
if((ADC12MEM0>=0x0A00&&ADC12MEM0<=0x0Bff)&&(ADC12MEM2>=0x0A00&&ADC12MEM2<=0X0BFF)&&(ADC12MEM3>=0X0A00&&ADC12MEM3<=0X0CFF)&&(ADC12MEM4>=0X0800&&ADC12MEM4<=0X09FF)&&(ADC12MEM5>=0X0C00&&ADC12MEM5<=0X0CFF))//(0x0A00<=A0results<=0x0Aff)&&(0x0A00<=A2results<=0x0B50)&&(0x0A00<=A3results<=0x0BFF)&&(0x0850<=A4results<=0x09FF)&&(0x0C00<=A5results<=0x0CFF))
//P5SEL=0X00;
//P5DIR=0XFF;
P5OUT=0X77;
else
if((ADC12MEM0>=0x0B00&&ADC12MEM0<=0x0Bff)&&(ADC12MEM2>=0x0800&&ADC12MEM2<=0X08FF)&&(ADC12MEM3>=0X0700&&ADC12MEM3<=0X07FF)&&(ADC12MEM4>=0X0600&&ADC12MEM4<=0X06FF)&&(ADC12MEM5>=0X0800&&ADC12MEM5<=0X08FF))
P5OUT=0x7C;
else
if((ADC12MEM0>=0x0A00&&ADC12MEM0<=0x0Aff)&&(ADC12MEM2>=0x0900&&ADC12MEM2<=0X09FF)&&(ADC12MEM3>=0X0800&&ADC12MEM3<=0X08FF)&&(ADC12MEM4>=0X0700&&ADC12MEM4<=0X07FF)&&(ADC12MEM5>=0X0900&&ADC12MEM5<=0X09FF))
P5OUT=0x39;
else
if((ADC12MEM0>=0x0B00&&ADC12MEM0<=0x0Bff)&&(ADC12MEM2>=0x0800&&ADC12MEM2<=0X08FF)&&(ADC12MEM3>=0X0B00&&ADC12MEM3<=0X0BFF)&&(ADC12MEM4>=0X0900&&ADC12MEM4<=0X09FF)&&(ADC12MEM5>=0X0C00&&ADC12MEM5<=0X0CFF))
P5OUT=0x5E;
else
if((ADC12MEM0>=0x0A00&&ADC12MEM0<=0x0Aff)&&(ADC12MEM2>=0x0A00&&ADC12MEM2<=0X0AFF)&&(ADC12MEM3>=0X0900&&ADC12MEM3<=0X09FF)&&(ADC12MEM4>=0X0800&&ADC12MEM4<=0X08FF)&&(ADC12MEM5>=0X0A00&&ADC12MEM5<=0X0AFF))
P5OUT=0x79;
else
P5OUT=0X00;
}
in the analog input pins where the sensor is connected i am getting the voltage values but not entering ISR
Last edited: