新闻  |   论坛  |   博客  |   在线研讨会
S3c2440-ARM920t中断原理
xiajiashan | 2012-08-28 16:35:05    阅读:823   发布文章

 

作者:下家山(转载,请注明)

一:60个中断源

S3c2440共有60个中断源。

主中断源如下:1.jpg

子中断源如下:
 
 
4.jpg
二:中断优先级

S3c2440共有7组基于优先级轮转的冲裁机制来控制32个中断源。

5.jpg

 

说明:

①ARBITER6所控制的REQ0,1,2,3,4,5实际上对应ARBITER0,1,2,3,4,5

②REQ0在任何情况下具有最高优先级,REQ5具有最低优先级;

对这句话的理解:

对ARBITER1-4来说,在任何情况下:REQ0具有最高优先级,REQ5具有最低优先级

对ARBITER6来说,在任何情况下:ARBITER0具有最高优先级,ARBITER5具有最低优先级

2.1 优先级控制原理

S3c2440是通过Priority Register(优先级寄存器)来控制32个中断请求的,而在这个寄存器中是通过ARB_MOD(PRIORITY[6:0])和ARB_SEL(PRIORITY[20:7])来区分优先级的。

 

 
 
6.jpg
2.1.1 当ARB_MOD为0

REQ1-4(REQ0,5优先级固定)优先级不轮转,顺序即为开始设置好的顺序。

复位值:

ARB_SEL0 00 优先级次序:REQ1>REQ2>REQ3>REQ4(即:EINT0>EINT1>EINT2>EINT3);

ARB_SEL1 00 优先级次序:REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

(即:EINT4_7>EINT8_23>INT_CAM>Nbatt_FLT>INT_TICK>INT_WDT/AC97);

ARB_SEL2 00 优先级次序:REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

(即:INT_TIMER0> INT_TIMER1> INT_TIMER2> INT_TIMER3> INT_TIMER4> INT_UART2);

ARB_SEL3 00 优先级次序:REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

(即:INT_LCD> INT_DMA0> INT_DMA1> INT_DMA2> INT_DMA3> INT_SDI);

ARB_SEL4 00 优先级次序:REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

(即:INT_SPI0> INT_UART1> INT_NFCON> INT_USBD> INT_USBH> INT_IIC);

ARB_SEL5 00 优先级次序:REQ1>REQ2>REQ3>REQ4

(即:INT_UART0>INT_SPI1>INT_RTC> INT_ADC);

其他组值:

ARB_SEL bits are 01b, the priority order is REQ0, REQ2, REQ3, REQ4, REQ1, and REQ5.

ARB_SEL bits are 10b, the priority order is REQ0, REQ3, REQ4, REQ1, REQ2, and REQ5.

ARB_SEL bits are 11b, the priority order is REQ0, REQ4, REQ1, REQ2, REQ3, and REQ5.

具体优先级次序不一一列出。

 

 

2.1.2 当ARB_MOD为1

当ARB_MOD==1,REQ1-4优先级次序会随着当前中断服务程序轮转:

(REQ0和REQ5因为优先级固定而不参与轮转)

If REQ0 or REQ5 is serviced, ARB_SEL bits are not changed at all.

If REQ1 is serviced, ARB_SEL bits are changed to 01b.

If REQ2 is serviced, ARB_SEL bits are changed to 10b.

If REQ3 is serviced, ARB_SEL bits are changed to 11b.

If REQ4 is serviced, ARB_SEL bits are changed to 00b.

上面是来自s3c2440 datasheet的原话,怎么理解呢?

ARB_SEL bits are 00b, the priority order is REQ0, REQ1, REQ2, REQ3, REQ4, and REQ5.

ARB_SEL bits are 01b, the priority order is REQ0, REQ2, REQ3, REQ4, REQ1, and REQ5.

ARB_SEL bits are 10b, the priority order is REQ0, REQ3, REQ4, REQ1, REQ2, and REQ5.

ARB_SEL bits are 11b, the priority order is REQ0, REQ4, REQ1, REQ2, REQ3, and REQ5.

如果ARB_SEL初始值为00,即优先级次序为REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

当当前中断是REQ1,并且处理完毕,则ARB_SEL自动改变到01,即优先级次序轮转一次变成REQ0> REQ2>REQ3>REQ4>REQ1>REQ5

紧接着REQ2中断发生并处理完毕,则ARB_SEL自动改变到10,即优先级次序轮转一次变成REQ0> REQ3>REQ4>REQ1>REQ2>REQ5

再接着REQ3中断发生并处理完毕,则ARB_SEL自动改变到11,即优先级次序轮转一次变成REQ0> REQ4>REQ1>REQ2>REQ3>REQ5

最后REQ3中断发生并处理完毕,则ARB_SEL自动改变到00,即优先级次序轮转一次变成REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

REQ1>REQ2>REQ3>REQ4就像一个链条或者说是一个履带,每发生一次中断就转动一次。

 

这里会有一个矛盾:

当ARB_SEL初始值为00,即优先级次序为REQ0> REQ1>REQ2>REQ3>REQ4>REQ5

此时:我们只用了REQ0,REQ1,REQ3,REQ4

当REQ3发生,并处理完毕。ARB_SEL值应该是多少???

应该为11?

三:中断控制原理

S3c2440的中断控制原理可以通过下面的图体现出来:

 

7.jpg

可是这个图却有几个地方让人模棱两可。

疑问一:SUBSRCPND SRCPND INTPND

疑问二:SUBMASK MASK

我们来看s3c2440 datasheet的定义:

3.1 Interrupt Pending Register

The S3C2440A has two interrupt pending registers: source pending register (SRCPND) and interrupt pending register(INTPND). These pending registers indicate whether an interrupt request is pending or not. When the interrupt sources request interrupt the service, the corresponding bits of SRCPND register are set to 1, and at the same time,only one bit of the INTPND register is set to 1 automatically after arbitration procedure. If interrupts are masked, then the corresponding bits of the SRCPND register are set to 1. This does not cause the bit of INTPND register changed.When a pending bit of INTPND register is set, the interrupt service routine will start whenever the I-flag or F-flag is cleared to 0. The SRCPND and INTPND registers can be read and written, so the service routine must clear the pending condition by writing a 1 to the corresponding bit in the SRCPND register first and then clear the pending condition in the INTPND registers by using the same method.

 

3.2关于SRCPND INTPND

当一个中断源被请求【(主中断源,即不带子中断的中断源),例如某一个外部中断引脚上出现了低电平(一般是低电平或下降沿触发中断)】

如果中断没有被屏蔽:

SRCPND对应位将置1。

与此同时,INTPND中的某一个位在得到优先级冲裁后(对应中断位)将自动置1。

如果中断被屏蔽:

SRCPND对应位将置1。

但此时,该中断不会被冲裁,也不会改变INTPND相关位,如上图所示,在MASK地方就被截断了。

3.3关于 INTPND

当INTPND某一个位被置位,此时只要CPSR中的I-flag或F-flag被置位,中断函数就会被执行。

四:外部中断 4.1 外部中断与主中断的关系
9.jpg

 

从上图可以一目了然的看出EINT8-23和EINT8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23之间的关系(EINT4-7和EINT4,5,6,7)。

4.2 外部中断控制原理

 

11.jpg

 

外部中断触发方式:[主要设置是电平触发(是高还是低)还是边沿触发(是上升沿还是下降沿,还是双边沿)]

五:结束语

中断部分,是整个arm架构中比较难理解的部分,本文有不正确之处,请与我讨论。可以跟我发邮件!(ximenpiaoxue4016@sina.com)

转载:请注明,作者,下家山 请尊重原创!

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
02年接触ARM和ucos,开发过有线和无线图像报警器,IPCamera,人脸识别系统,OCR识别系统,指纹识别系统,05年开始从事Linux及Rtems下WiFi,camera,Ethernet等驱动开发工作,专做嵌入式linux培训,致力于把我十年来的研发经验传授给每一个学员,招人的可以找我,ximenpiaoxue4016@sina.com
推荐文章
最近访客