要T0 T1产生中断其实很容易,开 ET0 允许中断,然后开 EA 就行了。
; MCU : AT89S52 at 12MHZ
; Compiler: Keil C51
; Author : Etual
; Date : 2012-1-7
;-------------------------------------------------
; vector
;-------------------------------------------------
ORG 00H
LJMP RESET_HANDLER
ORG 0BH
LJMP INT_T0
ORG 1BH
LJMP INT_T1
;-------------------------------------------------
; main program
;-------------------------------------------------
INT_T0:
PUSH ACC
PUSH PSW
CPL P1.0
POP PSW
POP ACC
RETI
INT_T1:
PUSH ACC
PUSH PSW
CPL P1.1
POP PSW
POP ACC
RETI
;-------------------------------------------------
; main program
;-------------------------------------------------
RESET_HANDLER:
MOV SP,#70H
MAIN:
CALL SYSTEM_INIT
MOV TMOD,#12H
SETB TR0
SETB TR1
SETB ET0
SETB ET1
SETB EA
LOOP:
JMP LOOP
;-------------------------------------------------
; sub routine
;-------------------------------------------------
; SYSTEM INIT
SYSTEM_INIT:
SYSTEM_INIT_END:
RET
END