QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4606|回复: 1

ucos4skyeye中断安装函数有点不理解

[复制链接]
发表于 2013-7-23 11:00:15 | 显示全部楼层 |阅读模式
void install_irqhandler(void * isr)
{
        /* ARM irq exception vector addr is 0x00000018  */
        unsigned int * irq_vec_addr = ( unsigned int * ) 0x18;

        /* this is isr entry address, could be another address like 0x3c, 0x58... */
        unsigned int * isr_entry_addr = ( unsigned int * ) 0x38;

        unsigned int instruction;
      
        /* set the ISR entry at 0x38  */
        *isr_entry_addr = (unsigned int)isr;
      
        /* make an instruction: it is machine-code for "ldr  pc, [pc, #(38-18-]"  */
/* pc是预取指令,会自动加8所以要得出中断处理函数地址的偏移量就后再减去pc事

  先自动加上的8才得到真正的偏移量 */
        instruction = ((unsigned int) isr_entry_addr  - (unsigned int)irq_vec_addr - 0x0 | 0xe59ff000;
      
        /* set this instruction at 0x18  */
        *irq_vec_addr = instruction;      
}
我的理解是当irq中断发生,从向量表0x18跳转到0x38去寻找中断处理函数。问题是0x38只是存放了isr的地址,没有使用ldr之类的指令pc指针怎么从0x38又跳转到isr的地址的呢?
 楼主| 发表于 2013-7-25 09:39:04 | 显示全部楼层
看代码不仔细,结贴了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-20 01:00 , Processed in 0.055178 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表