2010-03-22 21:02:42     a problem about the IRQ task

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-03-22 21:02:42     a problem about the IRQ task

zhang zhihua (CHINA)

Message: 87594   

 

我首先在驱动程序里面配置PH4为外部中断的入口:

 

*pPORTH_FER1 &= 0xFFEA; //配置PH2 PH0 PH4为GPIO

*pPORTHIO_DIR1 &= 0xFFEE;// 配置PH4 PH0输入

 

然后申请IRQ_PH4为中断号的中断:

 

request_irq (IRQ_PH4,my_task1,IRQF_TRIGGER_FALLING,TEST_DEVICE_NAME,NULL);

 

中断处理程序如下:

 

static irqreturn_t my_task1(int irq,void *dev_id)

{

disable_irq(IRQ_PH4);

printk("This is the irq_task1!\n");

/**********************************************/

//调用处理函数

/**********************************************/

  enable_irq(IRQ_PH4);

  return IRQ_HANDLED;

}

 

编译之后下载内核到目标板,然后编写了一个test程序,申请中断成功,但是我在PH4口用导线点一个低电平后发现进入中断后就一直打印 This is the irq_task1! 使用Ctrl+C都没办法终止,过一会儿系统就自动重新启动了...

 

TranslateQuoteReplyEditDelete

 

 

2010-03-22 21:08:12     Re: a problem about the IRQ task

Mike Frysinger (UNITED STATES)

Message: 87595   

 

do not touch any PORTMUX-ing related MMRs.  the IRQ framework takes care of programming things correctly.

QuoteReplyEditDelete

 

 

2010-03-22 22:57:12     Re: a problem about the IRQ task

Sonic Zhang (CHINA)

Message: 87597   

 

You should never access

 

*pPORTH_FER1 &= 0xFFEA; //配置PH2 PH0 PH4为GPIO

*pPORTHIO_DIR1 &= 0xFFEE;// 配置PH4 PH0输入

 

by yourself.

 

request_irq() do it for you already.

QuoteReplyEditDelete

 

 

2010-03-22 23:36:21     Re: a problem about the IRQ task

zhang zhihua (CHINA)

Message: 87599   

 

Hi,Sonic,

 

    PORTH_FER、PORTH_FER这些宏定义在哪个头文件呢?我没找到所以自己定义了,还有就是在我的中断处理程序里面是不是需要先把中断状态寄存器SIC_ISR清零呢?它的地址是多少呢?我查了文档没找到... ...

 

谢谢!

TranslateQuoteReplyEditDelete

 

 

2010-03-23 00:33:39     Re: a problem about the IRQ task

zhang zhihua (CHINA)

Message: 87600   

 

为什么进入中断处理程序就出不来呢?而且重复调用处理程序直至系统重启

TranslateQuoteReplyEditDelete

 

 

2010-03-24 05:14:46     Re: a problem about the IRQ task

Yi Li (CHINA)

Message: 87660   

 

zhang zhihua,

 

Please read:   docs.blackfin.uclinux.org/doku.php?id=linux-kernel:interrupts

 

Please note, in Linux, you don't need to touch irq control registers to handle irq, you will need to use high level API, e.g request_irq()

 

在你描述的这种情况下,你可能需要设置“IRQF_TRIGGER_LOW“.

 

另外,强烈建议阅读有关Linux 设备驱动的书籍,并参考已经有的驱动,否则在开发中可能遇到很多问题,浪费你很多时间。

 

-Yi

Attachments

    Outcomes