#include<LPC21xx.h>
#define uint8 unsigned char
#define uint32 unsigned int
void Timer0_ISR(void) __attribute__ ((interrupt));
uint8 num;
void DelayNs(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=5000;i>0;i--);
}
void Timer0_ISR(void)
{
T0IR = 0X01;
IO0SET = 0X00000001;
DelayNs(400);
IO0CLR = 0X00000001;
}
void Timer0Init(void)
{
T0IR = 0X01; /* 匹配通道0中断标志 */
T0PR = 99; /* 预分频寄存器 */
T0MCR = 0X03; /* MR0与TC匹配将使TC复位,且产生中断 */
T0MR0 = 110592/100; /* 匹配寄存器与定时器计数值想比较 */
T0TCR = 0x01; /* 启动定时器 */
VICIntSelect = 0; /* 中断选择寄存器,对应的中断请求分配为IRQ */
VICVectCnt10 = 0x00000024; /* VIC4通道 */
VICVectAddr0 = (int)Timer0_ISR; /* 向量地址寄存器 */
VICIntEnable = 0x00000010; /* 使能中断,写入1使能中断*/
}
int main()
{
PINSEL0 = 0X00000000;
IO0DIR = 0X00000001;
Timer0Init();
while(1);
}
/* 请问各位大虾,我想使用的是定时器0的匹配中断,进入中断后让P0.0的灯亮,可是怎么也进不了中断 恳请大虾们帮忙,谢谢了*/ |