Está en la página 1de 4

;

; semaforo.asm
;
; Created: 10/23/2016 3:59:37 PM
; Author : micros
;
.include "m328pdef.inc"//Biblioteca con definiciones y caracteristicas del micro
controlador a usar.
.device ATMega328P //Dispositivo microcontrolador ATMega328P
LDI R16,0xFF ; Carga de registro inmediato para incializar
salida
OUT DDRC,R16 ; Configura el puerto B como salida
LDI R16,0x04 ; ubica al apuntador de pila al final de SRAM
por que hay un llamado a rutina
OUT SPH,R16
LDI R16,0x5F
OUT SPL,R16
Lazo: ;lazo infinito
SBI PORTC,0 ;primer ciclo
CBI PORTC,1
CBI PORTC,2
CBI PORTC,3
CBI PORTC,4
SBI PORTC,5
RCALL Espera_500ms ;bloque de 15 seg
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
SBI PORTC,0 ;segundo ciclo
CBI PORTC,1
CBI PORTC,2
CBI PORTC,3
CBI PORTC,4
SBI PORTC,5
RCALL Espera_500ms
CBI PORTC,5
RCALL Espera_500ms
SBI PORTC,5
RCALL Espera_500ms
CBI PORTC,5
RCALL Espera_500ms
SBI PORTC,5
RCALL Espera_500ms
CBI PORTC,5
RCALL Espera_500ms
SBI PORTC,5
RCALL Espera_500ms
CBI PORTC,5
RCALL Espera_500ms
SBI PORTC,5
RCALL Espera_500ms
CBI PORTC,5
RCALL Espera_500ms
SBI PORTC,5
SBI PORTC,0 ;tercer ciclo
CBI PORTC,1
CBI PORTC,2
CBI PORTC,3
SBI PORTC,4
CBI PORTC,5
RCALL Espera_500ms ;bloque de 5 seg
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
CBI PORTC,0 ;cuarto ciclo
CBI PORTC,1
SBI PORTC,2
SBI PORTC,3
CBI PORTC,4
CBI PORTC,5
RCALL Espera_500ms ;bloque de 15 seg
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
CBI PORTC,0 ;quinto ciclo
CBI PORTC,1
SBI PORTC,2
SBI PORTC,3
CBI PORTC,4
CBI PORTC,5
RCALL Espera_500ms
CBI PORTC,2
RCALL Espera_500ms
SBI PORTC,2
RCALL Espera_500ms
CBI PORTC,2
RCALL Espera_500ms
SBI PORTC,2
RCALL Espera_500ms
CBI PORTC,2
RCALL Espera_500ms
SBI PORTC,2
RCALL Espera_500ms
CBI PORTC,2
RCALL Espera_500ms
SBI PORTC,2
RCALL Espera_500ms
CBI PORTC,2
RCALL Espera_500ms
CBI PORTC,2
CBI PORTC,0 ;sexto ciclo
SBI PORTC,1
CBI PORTC,2
SBI PORTC,3
CBI PORTC,4
CBI PORTC,5
RCALL Espera_500ms ;bloque de 5 seg
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RCALL Espera_500ms
RJMP Lazo
;una rutina de espera se debe revisar de lazo interno al externo
;500ms = 500 000 us = 2x(250x(250x4us))
;
Espera_500ms:
LDI R18,2
et3: LDI R17,250
et2: LDI R16,250
et1: NOP ;intera 250 veces,emplea 4us por interacion
DEC R16 ;250x4us=1000us=1ms
BRNE et1 ;la instruccion evalua la bandera de cero
DEC R17
BRNE et2 ; 1msx250=250ms
DEC R18
BRNE et3 ; 250msx2=500ms
RET

También podría gustarte