各位好!
想请问一个6678中断的问题,问题是在中断初始化时,将核级、片级等初始化放在一个函数下进行初始化,可以正常触发片级中断,如函数Func,但是如果将初始化函数分开为四个部分(见Func中对应的Func1,Func2,Func3,Func4),初始化顺序不变,则不能正常触发片级中断,查看各种寄存器也没有发现什么异常,总之,拆成四个之后就是进不了中断服务函数,实在没办法了,想请问各位大神指导一下!非常感谢!
//全局变量
CSL_IntcEventHandlerRecord recordTable[30];
CSL_CPINTC_Handle cpHandle0;
CSL_CPINTC_Handle cpHandle1;
CSL_CPINTC_Handle cpHandle2;
CSL_CPINTC_Handle cpHandle3;
Bool Func(Uint16 EventId,Uint8 VectId,void interruptISR(), Uint8 ChipIntNum, Uint16 SysEventId, Uint16 ChannelId){
//核级
//Func1
CSL_IntcGlobalEnableState state;
CSL_IntcContext context;
context.numEvtEntries = 10;
context.eventhandlerRecord = (CSL_IntcEventHandlerRecord*)&recordTable;
if (CSL_intcInit(&context) != CSL_SOK) return 0;
if (CSL_intcGlobalNmiEnable() != CSL_SOK) return 0;
if (CSL_intcGlobalEnable(&state) != CSL_SOK) return 0;/**/
//Func2
//片级中断控制器0~3初始化
cpHandle0 = CSL_CPINTC_open(0);
if (cpHandle0 == 0) return 0;
cpHandle1 = CSL_CPINTC_open(1);
if (cpHandle1 == 0) return 0;
cpHandle2 = CSL_CPINTC_open(2);
if (cpHandle2 == 0) return 0;
cpHandle3 = CSL_CPINTC_open(3);
if (cpHandle3 == 0) return 0;
CSL_CPINTC_disableAllHostInterrupt(cpHandle0);
CSL_CPINTC_setNestingMode (cpHandle0, CPINTC_NO_NESTING);
CSL_CPINTC_enableAllHostInterrupt(cpHandle0);
CSL_CPINTC_disableAllHostInterrupt(cpHandle1);
CSL_CPINTC_setNestingMode (cpHandle1, CPINTC_NO_NESTING);
CSL_CPINTC_enableAllHostInterrupt(cpHandle1);
CSL_CPINTC_disableAllHostInterrupt(cpHandle2);
CSL_CPINTC_setNestingMode (cpHandle2, CPINTC_NO_NESTING);
CSL_CPINTC_enableAllHostInterrupt(cpHandle2);
CSL_CPINTC_disableAllHostInterrupt(cpHandle3);
CSL_CPINTC_setNestingMode (cpHandle3, CPINTC_NO_NESTING);
CSL_CPINTC_enableAllHostInterrupt(cpHandle3);
//Func3
CSL_IntcHandle hIntc;
CSL_IntcObj intcObj;
CSL_IntcEventHandlerRecord EventRecord;
CSL_IntcParam IntId;
IntId = (CSL_IntcParam)VectId;
hIntc = CSL_intcOpen (&intcObj, EventId, &IntId , NULL);
EventRecord.handler = interruptISR;
EventRecord.arg = (void *)EventId;
CSL_intcPlugEventHandler (hIntc, &EventRecord);
if (CSL_intcHwControl(hIntc,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK) return 0;
//Func4
CSL_CPINTC_Handle hnd;
switch(ChipIntNum)
{
case 0:
hnd = cpHandle0;
break;
case 1:
hnd = cpHandle1;
break;
case 2:
hnd = cpHandle2;
break;
case 3:
hnd = cpHandle3;
break;
default:
break;
}
CSL_CPINTC_mapSystemIntrToChannel (hnd, SysEventId, ChannelId);
CSL_CPINTC_enableSysInterrupt (hnd, SysEventId);
CSL_CPINTC_enableHostInterrupt (hnd, ChannelId);
return 1;
}
void main()
{
pll初始化等
Func();
触发片级中断
}//可以进入中断服务函数
void main()
{
pll初始化等
Func1();
Func2();
Func3();
Func4();
触发片级中断
}//该初始化则不能够进入中断