Red de conocimiento informático - Conocimiento sistemático - Los tres LED del microcontrolador del conjunto 51 parpadean alternativamente

Los tres LED del microcontrolador del conjunto 51 parpadean alternativamente

ORG 0000H

AJMP PRINCIPAL

ORG 000BH; TO Interrupción de tiempo

lJMP T0INT

ORG 001BH; Interrupción de conteo T1

LJMP T1CNT

ORG 030H

PRINCIPAL: MOV TMOD, #61H; conteo T1 en MOD 2, tiempo T0 int en MOD 1

MOV TL0, #0B0H; 66536-50000=3CB0H 50000us=50ms=0.05s

MOV TH0, #3CH

SETB ET0; >

SETB TR0; T0 funciona

; MOV TL1, #0FDH; número de cuenta = 2

; > ; SETB ET1

; SETB TR1

SETB EA ; Habilitar todas las interrupciones

MOV A, #28H ;0.05s*40=2s

MOV P0, #0FEH

JMP $

ORG 060H

T0INT: CLR ET0; Deshabilitar interrupción T0

CLR TF0 ;clr tf0

;CPL P1.7

DEC A ;A--

JNZ T0RET ;A!=0 jmp

;;;;;;;;;;;;;;;;;;;Cambie aquí para cambiar el parpadeo de la luz

MOV A, P1

RR A

MOV P1, A

;;;;;;;;;;;;;;;;

MOV A, #28H; A==0; 40 ,

T0RET: SETB ET0; Habilitar interrupción

RETI

ORG 080H