论坛» 嵌入式开发» MCU

中断驱动函数为何会死掉?

菜鸟
2004-08-05 00:24 1楼

我写了一个响应外边中断的驱动程序

但是在进入中断驱动函数时,系统常常会死掉。

如果只是在中断处理函数执行printk这种简单操作,中断可以正确执行。
但如果我在中断驱动函数中放入一些复杂一点的操作代码或者调用其它函数。

系统常常在执行到open函数时,内核就自动进中断(这时并没有中断源),而且死在里面了。

open函数只是执行open device和一些初始化,它怎么自己进去中断了,而且死在里面了.

我的系统是s3c4510B。

希望各位大虾帮忙啊! [align=right][color=#000066][此贴子已经被作者于2004-8-4 16:49:27编辑过][/color][/align]

菜鸟
2004-08-05 01:35 2楼
void HDLC_read_service(int irq,void *dev_id,struct pt_regs *regs)//中断处理函数
{
printk("\n(----K----)INTERRUPT EXECUTED!(----K----)\n");
int i,k;
BYTE rLen;
BYTE rBuf[512]; BYTE Channel; UWORD16 HdlcQueueData;
UWORD16 * HdlcQueue; if( HdlcReg[HDLC_IR] & 0x01 )
{
for(i=0;i{
SetRamPage(InitBlockPage);
HdlcQueue=(UWORD16 *)(St5465_Mem_BaseAddr+HdlcQueue_BaseAddr);
HdlcQueueData=HdlcQueue[i];
HdlcQueue[i]=0x00;
if( HdlcQueueData & 0x8000 ) file://HDLCINT NOT APPLIED YET
{
if( HdlcQueueData & 0x2000 ) // Tx
{

}
else // Rx
{
Channel = ( (HdlcQueueData & 0x1F00) >> 8 );

rLen = GetHdlcFrame(Channel,rBuf);
if(rLen > 0 && rLen < 63)
{
printk("\n(----K----)Receive From Hdlc Port %2d : ",Channel);
for(k=0;kprintk("%02x ",rBuf[k]); }

}
} }
} }
struct file_operations arm7_fops = {
read: read_Arm7,
write: write_Arm7,
open: open_Arm7,
release: release_Arm7,
}; int hdlc_init(void)
{ int result;
result = register_chrdev(254, "hdlc", &arm7_fops);
if (result < 0)
{
printk("(----K----)Test: can't register the test driver\n");
return(-1);
} if (Arm7_major == 0)
Arm7_major = result;
printk("(----K----)Major Number=%d\n",result); result=request_irq(HDLC_READ_IRQ,&HDLC_read_service,SA_INTERRUPT,"HDLC_read",NULL);
INT_ENABLE(HDLC_READ_IRQ); //注册使能中断

if (result == -1)
{
printk("(----K----)Can't get assigned irq %d\n",HDLC_READ_IRQ);
return -1;
} return(0);
}
菜鸟
2004-08-05 01:37 3楼
以上是程序主要的部分
共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册]