KEIL4,其中 lpc2148 ADC 中断或 IRQ 不会执行

发布于 2025-01-10 07:41:05 字数 1505 浏览 2 评论 0原文

我已经为处理器 LPC 2148 的 ADC 通道 AD0.1 配置了 ISR。但是,当 ADC 值发生变化时,ISR 并未执行。因为这个VICVectAddr包含ISR函数的值。该计划是学习的一部分。 请找到下面的代码。如果有人给出解决方案,这将非常有帮助


 
#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;
}

    ```

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;
}

    ```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文