_DINT(); 关总中断 (可用于保护不希望受到中断打断的程序)
例子:_DINT();_()NOP; //在保护程序之前与关中断之间最少有一步操作。DINT Disable (general) interrupts Syntax DINT
Operation 0 → GIE
or
(0FFF7h .AND. SR → SR / .NOT.src .AND. dst → dst)
Emulation BIC #8,SR
Description All interrupts are disabled.
The constant 08h is inverted and logically ANDed with the SR. The result is placed into
the 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 move
of a 32-bit counter. This ensures that the counter is not modified during the move by any
interrupt.
DINT ; All interrupt events using the GIE bit are disabled
NOP
MOV COUNTHI,R5 ; Copy counter
MOV COUNTLO,R6
EINT ; All interrupt events using the GIE bit are enabled
NOTE: Disable interrupt
If any code sequence needs to be protected from interruption, DINT should be executed at
least one instruction before the beginning of the uninterruptible sequence, or it should be
followed by a NOP instruction.
_EINT(); 开总中断 * EINT Enable (general) interrupts
Syntax EINT
Operation 1 → GIE
or
(0008h .OR. SR → SR / .src .OR. dst → dst)
Emulation BIS #8,SR
Description 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 &P1IN
BIC.B @SP,&P1IFG ; Reset only accepted flags
EINT ; Preset port 1 interrupt flags stored on stack
; other interrupts are allowed
BIT #Mask,@SP
JEQ 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.
RETI
NOTE: Enable interrupt
The 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:开可屏蔽中断