You are on page 1of 2

.

org $00
rjmp inicio

.org $02
rjmp interrupt0

.org $04
rjmp interrupt1

.org $34

inicio: ldi r16, $ff


ldi r17, $08
out spl, r16
out sph, r17

// INICIALIZACIÓN DE PUERTOS I/O E INTERRUPCIONES

sbi ddrb, 0 // PIN 0 DE PORTB COMO SALIDA (EL


LED)

// HABILITACION DE LAS INTERRUPCIONES INT0 E INT1

ldi r16, $0E // $02 $08


03 0C
sts eicra, r16

ldi r16, $03


out eimsk, r16

sei //SET GLOBAL INTERRUPT FLAG

// PROGRAMA PRINCIPAL

ciclo: rjmp ciclo

interrupt0: rcall retardito // SUBRUTINA DE SERVICIO


sbi portb , 0 // DE INTERRUPCION PARA
reti // LA INT 0

interrupt1: rcall retardito // SUBRUTINA DE SERVICIO


cbi portb, 0 // DE INTERRUPCION PARA
reti // LA INT 1

; =============================
; delay loop generator
; 50000 cycles:
; -----------------------------
; delaying 49995 cycles:
retardito: ldi R20, $65
WGLOOP0: ldi R21, $A4
WGLOOP1: dec R21
brne WGLOOP1
dec R20
brne WGLOOP0
; -----------------------------
; delaying 3 cycles:
ldi R20, $01
WGLOOP2: dec R20
brne WGLOOP2
; -----------------------------
; delaying 2 cycles:
nop
nop
RET
; =============================

You might also like