谁能帮我看看这段代码 的错误(不能进入中断函数) 编译器是EWARM
arm吧
全部回复
仅看楼主
level 1
cheneh123 楼主
/*************************************************************************
**
**                  **
**************************************************************************/
#include <intrinsics.h>
#include <stdio.h>
#include <nxp/iolpc2103.h>
// OSC [Hz]
#define FOSC             11059200UL
// Core clk [Hz]
#define FCCLK            FOSC
// Per clk [Hz]
#define PCCLK            (FOSC/4)
#define LED1CON   1
#define LED2CON   1<<1
typedef unsigned char   uint8;
typedef unsigned int    uint32;
/*************************************************************************
* 函数名称:irq_handler
* 入口参数:无
*
* 返回参数:无
*
* 描     述:IRQ handler
*
*************************************************************************/
//uint32   IRQV= 0x18;
#pragma vector=IRQV
__irq   void irq_handler (void)
{
void (*interrupt_function)();
unsigned int vector;
   vector = VICVectAddr;      //获得中断向量
   interrupt_function = (void(*)())vector;
   if(interrupt_function != NULL)
   {
     interrupt_function();   //调用中断指向的函数
   }
   else
   {
     VICVectAddr = 0;       //清除在VIC中的中断
   }
}
/*************************************************************************
* 函数名称: VicInit
* 入口参数: 无
*
* 返回参数: 无
*
* 说     明: Init VIC module
*
*************************************************************************/
void VicInit (void)
{
   // Assign all interrupt chanels to IRQ
   VICIntSelect   =   0;
   // Diasable all interrupts
   VICIntEnClear = 0xFFFFFFFF;
   // Clear all software interrutps
   VICSoftIntClear = 0xFFFFFFFF;
   // VIC registers can be accessed in User or privileged mode
   VICProtection = 0;
   // Clear interrupt
   VICVectAddr = 0;
   // Clear address of the Interrupt Service routine (ISR) for non-vectored IRQs.
   VICDefVectAddr = 0;
   // Clear address of the Interrupt Service routine (ISR) for vectored IRQs.
   VICVectAddr0   = VICVectAddr1   = VICVectAddr2   = VICVectAddr3   =\
   VICVectAddr4   = VICVectAddr5   = VICVectAddr6   = VICVectAddr7   =\

2011年02月06日 10点02分 1
level 1
cheneh123 楼主
   VICVectAddr8   = VICVectAddr9   = VICVectAddr10 = VICVectAddr11 =\
   VICVectAddr12 = VICVectAddr13 = VICVectAddr14 = VICVectAddr15 = 0;
   // Disable all vectored IRQ slots
   VICVectCntl0   = VICVectCntl1   = VICVectCntl2   = VICVectCntl3   =\
   VICVectCntl4   = VICVectCntl5   = VICVectCntl6   = VICVectCntl7   =\
   VICVectCntl8   = VICVectCntl9   = VICVectCntl10 = VICVectCntl11 =\
   VICVectCntl12 = VICVectCntl13 = VICVectCntl14 = VICVectCntl15 = 0;
}
/*************************************************************************
* 函数名称: Init_Pin
* 入口参数: 无
*
* 返回参数: 无
*
* 说     明: Init Pin
*
*************************************************************************/
void Init_Pin(void)
{
   PINSEL0=0x00000000;
PINSEL1 = (PINSEL1 & 0xFFFFFFFC) | 0x01;
  
}
/*************************************************************************
* 函数名称: Init_pll
* 入口参数: 无
*
* 返回参数: 无
*
* 说     明: Init PLL
*
*************************************************************************/
void Init_pll(void)
{
   // Disable PLL
   PLLCON = 0;
   // Write Feed
   PLLFEED = 0xAA;
   PLLFEED = 0x55;
   // Set periphery divider /4
   APBDIV_bit.APBDIV   = 0;
   // Set MAM fully enable
   MAMCR_bit.MODECTRL = 0;
   MAMTIM_bit.CYCLES   = 3;
   MAMCR_bit.MODECTRL = 2;
}
/*************************************************************************
       中断服务程序 IRQ_Server
*************************************************************************/
uint32 IRQ_Count = 0; /* 定义变量,对IRQ中断计数 */
void   IRQ_Server(void)
{
IRQ_Count++;
if (( IRQ_Count % 3) == 0) {
IOSET = LED1CON;              
}
else {
IOCLR = LED1CON;               
}
while((IOPIN & (1 << 16)) == 0) ; /* 等待按键松开 */
EXTINT = 0x01;                      /* 清中断标志 */
VICVectAddr = 0x00;               /* 向量中断结束 */
}
/*************************************************************************
* 函数名称: Delay
* 入口参数: n
*
* 返回参数: 无
*
* 描     述: Delay
*
*************************************************************************/
void Delay(uint32 n)
{
   while(n--);
  
}
/*************************************************************************
* 函数名称: main
* 入口参数: 无
*
* 返回参数: 无
*
* 描     述: main
*
*************************************************************************/
void main(void)
{
   Init_pll();
   // Memory map init flash memory is maped on 0 address
#ifdef FLASH
   MEMMAP_bit.MAP = 1;
#else
   MEMMAP_bit.MAP = 2;
#endif
   __disable_interrupt();
   VicInit();
   Init_Pin();
   IODIR=LED1CON|LED2CON;
  
   EXTMODE = 0x01; /* 跟下条语句一起决定低电平触发 */
   EXTPOLAR = 0x00;
  
   VICIntSelect = 0 << 14; /* 选择EINT0为FIQ中断 */
   VICVectCntl0 = 0x20 | 14; /* 将外部中断0分配给向量中断0 */
   VICVectAddr0 = (uint32)IRQ_Server; /* 设置中断服务程序地址 */
   __enable_interrupt();
   VICIntEnable = 1 << 14; /* 使能EINT0中断 */
   EXTINT = 0x01; /* 清除EINT0中断标志 */
   while(1)
   {
      IOSET=LED2CON;
      Delay(500000);
      IOCLR=LED2CON;
      Delay(500000);
   }
  
}

2011年02月06日 10点02分 2
level 1
cheneh123 楼主
是不是中断服务函数没有声明,,
2011年02月06日 10点02分 3
1