Chinaunix首页 | 论坛 | 博客
  • 博客访问: 90555
  • 博文数量: 19
  • 博客积分: 442
  • 博客等级: 下士
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-11 15:31
文章分类
文章存档

2011年(19)

分类: 嵌入式

2011-10-11 14:48:05

嵌入式系统用中断,而不用轮询。原因:省电。轮询耗电,系统无法进入睡眠模式。
 
中断控制器,中断向量表。写中断的话,向中断向量表注册你的ISR。
 
轮询用在什么场合:中断时间来不及。例如数据过来后。
一般先用中断,接到数据第一次来,然后轮询不断读取数据。读取光后,再恢复为中断。
 
范例(ARM7CPU)
inline void disableInt(void)
     int temp;
 
     asm{
         mrs temp,CPSR
         orr temp,temp,#0x80
         msr CPSR_c, temp
     }
}
 
inline void enableInt(void)
{
     int temp;
    
     asm{
         mrs temp,CPSR
         bic temp,temp,#0x80
         msr CPSR_c,temp
     }
}
 
嵌套中断注意防止数据混乱。
 
 
阅读(1848) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~