摘要
在MCU的中断被触发时,一般直接在中断处理函数里完成要执行的指令,但当遇到执行时间较长的指令时,例如上位机控制电机转动,如果仍然在中断处理函数中执行,则需要占用大量中断处理时间,对MCU的及时响应产生一定的影响。本文借鉴Linux系统的中断处理思想以及FPGA状态机思想,提出了一种利用状态机进行当前状态判断的方法。在中断处理函数里,对占用指令周期短的命令可直接在中断处理函数里执行,而对于占用时间长的命令,只做接收,处理过程放在主函数里执行。实验证明,这种方法可有效提高系统的响应性,同时方法简单,容易掌握。
When the MCU interrupt triggered, the instructions are executed in the interrupt processing functions normally. However, when the instructions execution time is longer, such as the electric machine control by the PC, if the instructions are still executed in the interrupt processing functions, this will use more interrupt processing time, and the system can ’t trigger the interrupt immediately. Base on the methods ofinterrupt processing of the Linux system and the state machine method of the FPGA, it gives a new method to judge the present state using the status machine in this article. In the interrupt processing function, the short time instructions can execute in the interrupt processing function directly, but to the long time instructions, just as receiver, and the instructions can process in the main function. Experimental verification, this method is simple and easy to learn, and improves the system respondent.
出处
《微计算机信息》
2011年第2期11-12,46,共3页
Control & Automation
基金
基金申请人:杨东军
项目名称:相敏绝对辐射计关键技术研究
基金颁发部门:吉林省科技厅(20090117)
关键词
中断处理
MCU
状态机
电机控制
interrupt processing
MCU
state machine
electric machine control