Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

doubt in interrupt g in mSP430f449

Status
Not open for further replies.

AnuHV

Member level 2
Joined
Nov 4, 2011
Messages
45
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,571
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
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;
   
 
}
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
 
Last edited:

Please someone help me
 

I think you need to know bit more about how to write the ISR.....in your case .....if you are writing ISR for ADC interrupts then you need to use ADC interrupt Flag....ISR is not a code the way that you are written.... It is the interrupted service routine that only get execute after an interrupt is triggered .....

How ever I don't have an example of ISR for ADC but I am posting a code with ISR for timer ....


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void isr ( void) __interrupt
{
    if(T0IF) // when interrupt occurs 
    {
 
/*
 
  //routing handled       
  if(( count <17))
        {
            count =count+1;
 
 
        }
        else
        {
            count=0;
 
            d4=d4+1;
            if((d4>d1)&&(d1>0))
            {
                d2=1;
            }
        }
*/
        TMR0 = 60; // Writing Timer0 register
        T0IF = 0;   // Clear interrupt flag
    }
}




I had put the interrupt routine in the block of /* and */ that is when I get an interrupt overflow from timer....it will do this thing for me....

refer it and try to modify it based on you need....

Good Luck
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top