|
用JLink在keil4+MDK+LPC2292的环境下仿真出现了一个问题:有的中断程序不执行,我初始化了两个定时中断服务程序 timer0_irq()和timer1_irq()
程序如下:
/*
*********************************************************************************************************
** 函数名称 :Timer0_irq()
** 函数功能 :定时器 1 中断服务程序
** 入口参数 :10us
** 出口参数 :
*********************************************************************************************************
*/
void __irq Timer0_irq()
{
static uint8 count100us = 0;
static uint8 count500us = 0;
static uint8 count1ms = 0;
flag10us = 1; // 10us time out flag = 1;
count100us++;
if(count100us>9) // 100us time out flag = 1;
{
count100us = 0;
flag100us = 1;
}
count500us++;
if(count500us > 49) // 500us time out flag = 1;
{
count500us = 0;
flag500us = 1;
}
count1ms++;
if(count1ms>99) // 1ms time out flag = 1;
{
count1ms = 0;
flag1ms = 1;
}
T0IR = 1 << 0; // 清除定时器0的MR0中断标志
// 在中断服务程序的最后必须清VICVectAddr寄存器
VICVectAddr = 0x00;
}
/*
*********************************************************************************************************
** 函数名称 :Timer1_irq()
** 函数功能 :定时器 1 中断服务程序
** 入口参数 :
** 出口参数 :
*********************************************************************************************************
*/
void __irq Timer1_irq()
{
static uint8 count100ms = 0;
static uint8 count500ms = 0;
IO3PIN = IO3PIN ^ (1<<WDI); //watching dog
flag10ms = 1; // 100ms flag
count100ms++;
if(count100ms > 9)
{
count100ms = 0; // 500ms flag
flag100ms = 1;
getTachoP(); // get 600ms tachoMeter pulse
getSpeedP(); // get 1000ms speedMeter pulse
}
count500ms++;
if(count500ms > 49)
{
count500ms = 0; // 500ms flag
flag500ms = 1;
}
T1IR = 1 << 1; // 清除定时器0的MR1中断标志
// 在中断服务程序的最后必须清VICVectAddr寄存器
VICVectAddr = 0x00;
}
/*
*********************************************************************************************************
** 函数名称 :Timer0Init()
** 函数功能 :定时器 1 初始化
** 入口参数 :
** 出口参数 :
*********************************************************************************************************
*/
void Timer0Init()
{
T0TC = 0; // 设置计数器初始值0
T0PR = 0; // 设置预分频值0
// 3: T0MCR|=3<<0 产生MR中断标志,同时复位T0TC寄存器
T0MCR |= 3 << 0; // 设置为MR0中断
//Fpclk --> 定时10us
T0MR0 = Fpclk/100000;
T0TCR |= 1<<0; // 启动定时器计数
//---- 定时器中断设置 ----------
VICVectCntl4 |= 0x20 | 4; // 分配向量IRQ slot
VICVectAddr4 = (uint32)Timer0_irq;
VICIntEnable |= 1 << 4;
}
/*
*********************************************************************************************************
** 函数名称 :Timer1Init()
** 函数功能 :定时器 1 初始化
** 入口参数 :
** 出口参数 :
*********************************************************************************************************
*/
void Timer1Init()
{
T1TC = 0; // 设置计数器初始值0
T1PR = 0; // 设置预分频值0
T1MCR |= 3 << 3; // 设置为MR1中断
//Fpclk --> 定时10ms
T1MR1 = Fpclk/100;
T1TCR |= 1<<0; // 启动定时器计数
//---- 定时器中断设置 ----------
VICVectCntl3 |= 0x20 | 5; // 分配向量IRQ slot
VICVectAddr3 = (uint32)Timer1_irq;
VICIntEnable |= 1 << 5;
}
在仿真调试的时候,只能进入timer0_irq()中断程序,timer1_irq()中断程序始终进不去,
在实际运行的过程中,程序是能够正常执行的,这种写法我在ADS中也多次用过,没有出现问题,有对Keil仿真比较了解的,帮忙看看
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|