1 year ago

#229333

test-img

SARATH

KEIL4 where the lpc2148 ADC Interrupts or IRQs wont execute

I have configured for the ADC channel AD0.1 of processor LPC 2148, with ISR. But while ADC value changes ISR is not executing. Because of this VICVectAddr contains the value of ISR function. This program is part of learning. Please find the Code below. It is very help full if anybody has given solution


 
#include <lpc214x.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h> 

#define SBIT_RESULT     6u
#define SBIT_CLCKDIV    8u
#define SBIT_BURST      16u
#define SBIT_START      24u
#define SBIT_PDN        21u
#define SBIT_EDGE       27u 
#define SBIT_DONE       31u 


  
  void ADC_Init (void);
 __irq void ADC_ISR  (void) ; 


void main(void) { 
  AD0CR=0x0;
  ADC_Init (); 
  while(1){
    
  }

}

void ADC_Init (void)
{
    PINSEL1 = 0x01000000 ;                 // ADC P0.28, AD0.1
    AD0INTEN =0x02;                        //On completetion of ADC channel 1 generate  interupt
    VICVectAddr5 = (unsigned int)ADC_ISR;  // address of the ISR
    VICVectCntl5 = (1<<5) | 18;            
     VICIntSelect &= ~ (1<<18); 
    VICIntEnable = (1<<18);  
    AD0CR = 0X00200D02;
    AD0CR |= 0x01000000;  
}
  
 // Interrupt Service Routine-ISR 
__irq void ADC_ISR(void) { 

    static int flag=0 ;
    int val;
    unsigned int data;
    bool readStatus;
    data = AD0GDR   ; 
    readStatus = data  & 0x80000000;
        if(readStatus){        
        val = data >>=6;
        val= val & 0x3FF;
        val=((val/1023.0)*3.3);
    }
    Delay(1000000);
    
    AD0INTEN =0x0;      //clear ADC  interrupt
    VICVectAddr = 0;
}

    ```

c

arm

interrupt-handling

adc

isr

0 Answers

Your Answer

Accepted video resources