|
2440+CE5,ap中增加TIMER2定时中断,为何无法进入中断?? (冰天雪地跪求)
[复制链接]
主程序:
:
PLC2->DT[900]=Init_TIMER2_Interrupt();
:
}
static UINT32 g_TIMER2Irq = IRQ_TIMER2;
static UINT32 g_TIMER2SysIntr = SYSINTR_UNDEFINED;
static HANDLE gTIMER2Thread;
static HANDLE gWaitEvent;
static UINT32 fuck1;
UINT16 Init_TIMER2_Interrupt(void)
{
DWORD IDThread;
TIMER= (_TIMER*)V_Alloc((LPVOID)(TIMER_PH), sizeof(_TIMER));
INTS= (_INTS*)V_Alloc((LPVOID)(INT_PH), sizeof(_INTS));
//调用TIMER2, SRC=1 000 000 HZ
TIMER->TCFG1&=~(0xf<<8);
TIMER->TCFG1|=0x0<<8; //div 2
TIMER->TCNTB2=1000; //每秒1000次
TIMER->TCMPB2=500;
TIMER->TCON&=~(0xf<<12);
TIMER->TCON|=0x2<<12;
TIMER->TCON&=~(0xf<<12);
TIMER->TCON|=0x9<<12; //启动TIMER-2+AUTO RELOAD模式
gWaitEvent= CreateEvent(NULL, FALSE, FALSE, NULL);
if (!gWaitEvent) return 0;
// 从 OAL 请求一个 SYSINTR 值
fuck1=KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_TIMER2Irq, sizeof(UINT32),&g_TIMER2SysIntr, sizeof(UINT32), NULL);
PLC2->DT[14]=fuck1&0xffff;
if (fuck1==NULL) return 1;
if (!(InterruptInitialize(g_TIMER2Irq , gWaitEvent, NULL, 0))) return 2;
// 创建一个TIMER2中断处理线程 IST
gTIMER2Thread= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TIMER2_IST,0, 0,&IDThread);
if (gTIMER2Thread== NULL) return 3;
return 4;
}
UINT32 TIMER2_IST(void)
{
DWORD ret;
PLC2->DT[6]++;
// 外部中断线程开始运行
while (1) {
PLC2->DT[8]++;
ret = WaitForSingleObject(gWaitEvent, INFINITE);
PLC2->DT[10]++;
if (ret == WAIT_OBJECT_0)
{
//测试有无中断
PLC2->DT[0]++;
}
else
{
PLC2->DT[2]++;
return 0;
}
// 通知内核: 中断处理结束
InterruptDone(g_TIMER2SysIntr);
}
return 1;
}
***********************
调用timer2 pwm中断如上:
调用中断的步骤正常,(返回值正常)
且
timer2的pwm有正常产生
但是...停在WaitForSingleObject(gWaitEvent, INFINITE);
就没继续往下跑,
各位弟兄阿)))))))))))))
肯定出手相救阿))))))))))))
|
|