微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > MSP430 怎么开关中断,开关中断的代码|命令

MSP430 怎么开关中断,开关中断的代码|命令

时间:11-25 来源:互联网 点击:

_DINT(); 关总中断 (可用于保护不希望受到中断打断的程序)
例子:
_DINT();
_()NOP; //在保护程序之前与关中断之间最少有一步操作。
DINT Disable (general) interrupts  
Syntax DINTOperation 0 → GIEor(0FFF7h .AND. SR → SR / .NOT.src .AND. dst → dst)Emulation BIC #8,SRDescription All interrupts are disabled.The constant 08h is inverted and logically ANDed with the SR. The result is placed intothe SR.Status Bits Status bits are not affected.Mode Bits GIE is reset. OSCOFF and CPUOFF are not affected.Example The general interrupt enable (GIE) bit in the SR is cleared to allow a nondisrupted moveof a 32-bit counter. This ensures that the counter is not modified during the move by anyinterrupt.DINT ; All interrupt events using the GIE bit are disabledNOPMOV COUNTHI,R5 ; Copy counterMOV COUNTLO,R6EINT ; All interrupt events using the GIE bit are enabled
NOTE: Disable interruptIf any code sequence needs to be protected from interruption, DINT should be executed atleast one instruction before the beginning of the uninterruptible sequence, or it should befollowed by a NOP instruction.  
 
_EINT(); 开总中断  
* EINT Enable (general) interruptsSyntax EINTOperation 1 → GIEor(0008h .OR. SR → SR / .src .OR. dst → dst)Emulation BIS #8,SRDescription All interrupts are enabled.The constant #08h and the SR are logically ORed. The result is placed into the SR.Status Bits Status bits are not affected.Mode Bits GIE is set. OSCOFF and CPUOFF are not affected.Example The general interrupt enable (GIE) bit in the SR is set.PUSH.B &P1INBIC.B @SP,&P1IFG ; Reset only accepted flagsEINT ; Preset port 1 interrupt flags stored on stack; other interrupts are allowedBIT #Mask,@SPJEQ MaskOK ; Flags are present identically to mask: jump......MaskOK BIC #Mask,@SP......INCD SP ; Housekeeping: inverse to PUSH instruction; at the start of interrupt subroutine. Corrects; the stack pointer.RETINOTE: Enable interruptThe instruction following the enable interrupt instruction (EINT) is always executed, even if an interrupt service request is pending when the interrupts are enabled.
__bis_SR_register():是将SR里的对应位置1,
__bic_SR_register_on_exit(CPUOFF); 是将SR里的CPUOFF位置0。
__bis_SR_register(CPUOFF + GIE) 的意思是
MSP430头文件里定义的一个函数,用于置位SR寄存器中的相应位。 CPUOFF:关闭CPU,进入低功耗模式 GIE:开可屏蔽中断


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top