大家好,
DSP6678设置GPO0中断,在中断内部设置一个计数器记下中断的次数。下载到核心0之后,直接运行,会程序死在_csl_intcIsrdispatch里面,计数器的值为2,说明程序进入中断2次。这是为什么?而我如果下载到核0之后,在中断函数里设置断点,单步执行,则可以看到计数器的值每次都会加一。我的代码如下,请问这是什么原因?是不是哪里错了?谢谢
void setgpio()
{
CSL_GpioHandle hGpio;
CSL_IntcContext intcContext;
CSL_IntcEventHandlerRecord EventHandler[3];
CSL_IntcObj intcObj0, intcobj8;
CSL_IntcHandle hTest0;
CSL_IntcGlobalEnableState state;
CSL_IntcEventHandlerRecord EventRecord0, EventRecord8;
CSL_IntcParam vectId;
Uint8 bankNum = 0;
// Open the CSL GPIO Module 0
hGpio = CSL_GPIO_open (0);
// Enable GPIO per bank interrupt for bank zero
CSL_GPIO_bankInterruptEnable (hGpio, bankNum); CSL_GPIO_setRisingEdgeDetect (hGpio, 0); // Set interrupt detection on GPIO pin 1 to rising edge
CSL_GPIO_setPinDirInput ( hGpio, 0 ) ; //set pin as input
intcContext.eventhandlerRecord = EventHandler;
intcContext.numEvtEntries = 3;
if (CSL_intcInit(&intcContext) != CSL_SOK)
{
return;
}
if (CSL_intcGlobalNmiEnable() != CSL_SOK)
{/* Enable NMIs */
return;
}
if (CSL_intcGlobalEnable(&state) != CSL_SOK)
{ /* Enable global interrupts */
return;
}
/* Open the INTC Module for Vector ID: 4 and Event ID: 90 (GPIO_n in C6678)*/
vectId = CSL_INTC_VECTID_6; //
hTest0 = CSL_intcOpen (&intcObj0, 90, &vectId , NULL); if (hTest0 == NULL)
{
return;
}
EventRecord0.handler = &gpio0_Isr; //bind interupt function to gpio0 interrupt
// EventRecord0.arg = 0;
EventRecord0.arg = hTest0;
if (CSL_intcPlugEventHandler(hTest0,&EventRecord0) != CSL_SOK)
{
return;
}
if (CSL_intcHwControl(hTest0,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK)
{
return;
}
printf ("Debug: gpio0 int config Completed\n");
}
volatile int gio0Cnt=0;
interrupt void gpio0_Isr()
{
gio0Cnt++;
}
下面是中断的汇编文件
vect.asm
;————————————————————–
;reference to the externally defined ISR
.ref _c_int00
.ref SRIO_Doorbell_ISR
.ref SRIO_Message_ISR
.ref Exception_service_routine
.ref exception_record
.global vectors
;————————————————————–
.sect ".text"
;create interrupt vector for NMINMI_ISR:
STW B1,*-B15[1]
;save some key registers when exception happens
MVKL exception_record,B1
MVKH exception_record,B1
STW B3, *+B1[0]
STW A4, *+B1[1]
STW B4, *+B1[2]
STW B14, *+B1[3]
STW B15, *+B1[4]
;jump to exception service routine
MVKL Exception_service_routine, B1
MVKH Exception_service_routine, B1
B B1
LDW *-B15[1],B1
NOP 4
;————————————————————–
;create interrupt vector for reset (interrupt 0)
VEC_RESET .macro addr
MVKL addr,B0
MVKH addr,B0
B B0
MVC PCE1,B0
NOP 4
.align 32
.endm
;create interrupt vector for other used interruptsVEC_ENTRY .macro addr
STW B0,*–B15
MVKL addr,B0
MVKH addr,B0
B B0
LDW *B15++,B0
NOP 4
.align 32
.endm
;create interrupt vector for unused interruptsVEC_DUMMY .macro
unused_int?:
B unused_int? ;dead loop for unused interrupts
NOP 5
.align 32
.endm
;————————————————————–
;interrupt vector table .sect "vecs"
.align 1024
vectors:
VEC_RESET _c_int00 ;RESET
VEC_ENTRY NMI_ISR ;NMI/Exception
VEC_DUMMY ;RSVD
VEC_DUMMY ;RSVD
VEC_ENTRY SRIO_Doorbell_ISR ;interrupt 4
VEC_ENTRY SRIO_Message_ISR ;interrupt 5
VEC_DUMMY
VEC_DUMMY ;interrupt 7
VEC_DUMMY ;interrupt 8 VEC_DUMMY ;interrupt 9
VEC_DUMMY ;interrupt 10
VEC_DUMMY ;interrupt 11
VEC_DUMMY ;interrupt 12
VEC_DUMMY ;interrupt 13
VEC_DUMMY ;interrupt 14
VEC_DUMMY ;interrupt 15
.end
Allen35065:
你这个中断配置很乱,即用了CSL的中断分发,又自己写了vector,对应vector里的中断完全不是GPIO的中断;
要么你参考CSL的例子,只用CSL的Dispatcher,不要自行改写vector;
要么完全手工配置vector和GPIO以及中断映射,不用CSL的Dispatcher。
jian zong1:
请教大神, 在中断处理函数内,弟一行加上"asm nop 1000" 才能进入中断,请问这是什么问题?如何解决??
Allen35065:
回复 jian zong1:
不应该出现这个问题,因为你加的这个asm nop 1000对于进不进中断没有逻辑的关系,可能还是其它地方的配置不对。
jian zong1:
回复 Allen35065:
大神,我去掉了asm nop 1000,重新编译。在复位DSP之后,然后加载out文件,运行程序可以正常进入GPIO中断。
不用CSL的Dispatcher, 如何映射GPIO0中断和GPIO8中断?能否给个例子?或者说下步骤谢谢
jian zong1:
回复 jian zong1:
请教专家,不用CSL怎么映射GPIO0中断,GPIO8中断。 现在就是卡在GPIO8中断不响应,项目比较急,能否给个例子?谢谢