我用IAR软件
#include "iolpc2103.h"
#include <intrinsics.h>
#include <stdio.h>
#define VPBDIV (*((volatile unsigned char *) 0xE01FC100))
#define IOPIN (*((volatile unsigned long *) 0xE0028000))
#define Fosc 11059200 //外部晶振频率 11.0592M
#define Fcclk (Fosc * 4) //处理器时钟 Fosc * 4
#define Fpclk (Fcclk / 4) * 1 //VPB时钏频率
#define Fcco (Fcclk * 4) //PLL的操作频
#define LED1 1 << 17
#define LED2 1 << 18
#define LED3 1 << 19
#define LED4 1 << 20
__fiq __arm void fiq_handler(void)
{
IOCLR = LED1|LED2|LED3|LED4;
}
void PLL_Init()
{
/* 设置系统各部分时钟 */
PLLCON = 1; //使能PLL£但不连接 PLLCON.E = 1,PLLCON.C = 0
if ((Fpclk / (Fcclk / 4)) == 1)
VPBDIV = 0; // VPBDIV = 0,则Fpclk = 1/4 Fcclk (复位值)
if ((Fpclk / (Fcclk / 4)) == 2)
VPBDIV = 2; //VPBDIV = 2,则Fpclk = 1/2 Fcclk
if ((Fpclk / (Fcclk / 4)) == 4)
VPBDIV = 1; //VPBDIV = 1,则Fpclk = Fcclk;
if ((Fcco / Fcclk) == 2)
PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
if ((Fcco / Fcclk) == 4)
PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
if ((Fcco / Fcclk) == 8)
PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
if ((Fcco / Fcclk) == 16)
PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
PLLFEED = 0xaa;
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0);
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
}
void GPIO_Init()
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000; //设置P0.16为EINT0
IODIR = LED1|LED2|LED3|LED4;
IOSET = LED1|LED2|LED3|LED4;
}
void VIC_Init()
{
VICIntEnClear = 0xffffffff; //中断全部使能关闭
VICSoftIntClear = 0xffffffff; //清除软件中断
VICProtection = 0; //清除VIC保护
VICVectAddr = 0; //清除向量IRQ中断服务程序地址
VICDefVectAddr = 0; //清除非向量IRQ中断服务程序地址
//清除所有向量IRQ地址
VICVectAddr0 = VICVectAddr1 = VICVectAddr2 = VICVectAddr3 = \
VICVectAddr4 = VICVectAddr5 = VICVectAddr6 = VICVectAddr7 = \
VICVectAddr8 = VICVectAddr9 = VICVectAddr10 = VICVectAddr11 = \
VICVectAddr12 = VICVectAddr13 = VICVectAddr14 = VICVectAddr15 = 0;
VICVectCntl0 = VICVectCntl1 = VICVectCntl2 = VICVectCntl3 = \
VICVectCntl4 = VICVectCntl5 = VICVectCntl6 = VICVectCntl7 = \
VICVectCntl8 = VICVectCntl9 = VICVectCntl10 = VICVectCntl11 = \
VICVectCntl12 = VICVectCntl13 = VICVectCntl14 = VICVectCntl15 = 0;
}
void EINT0_Init()
{
PINSEL1 = PINSEL1 | 0x01; //设轩P0.16连接到EINT0
VICIntSelect = 1<<14; //选择EINT0 为FIQ中断
VICIntEnable = 1<<14;
EXTMODE = 0x00; //使用电平触发
EXTPOLAR = 0x00; //低或下降沿
EXTINT = 0x01;
}
void main(void)
{
//PLL_Init();
GPIO_Init();
__disable_interrupt();
VIC_Init();
EINT0_Init();
__enable_interrupt();
while(1)
{
};
}
设置P0.16为EINT0,低电平触发,接是按键,调试的时候怎么都进不了中断? |