Rutina.ASM

Las siguientes rutinas se utilizaron para el control de LEDs mediante el PIc16F628A y los Demultiplexores.

;====================================
;Programa para la primera tablilla controladora
;de la parte uno del proyecto.
;====================================
list p=16F628A
movlw 00h
movwf 0Bh
clrf 05h ;secuencia para deshabilitar
movlw 07h ;operaciones de comparación en PORTA
movwf 1Fh ;y habilitar funciones I/O


bsf 03h,05h ;entrar al Banco1
movlw 08h ;configurar el oscilador interno en 4MHz
movwf 8Eh ;enviando 08h al registro PCON(8Eh
movlw 10h ;configurar las entradas y salidas del PORTB
movwf 86h ;desde TRISB
movlw 00h ;configurar todos los pines de PORTA
movwf 85h ;como salidas
bcf 03h,05h ;salir del Banco1


start


movlw 03h
movwf 25h
init1
decfsz 25h,01h
goto move1
goto move2
;====================================
;Secuencia para la primera rutina de movimiento
;de las barras de LEDs de un lado al otro de la barra
;====================================
move1


movlw 0Ch
movwf 05h ;Deshabilita demux 2 y habilita demux 1
movlw 00h
movwf 06h
call delay
movlw 04h
movwf 06h
call delay
movlw 02h
movwf 06h
call delay
movlw 06h
movwf 06h
call delay
movlw 01h
movwf 06h
call delay
movlw 05h
movwf 06h
call delay
movlw 03h
movwf 06h
call delay
movlw 07h
movwf 06h
call delay




movlw 08h
movwf 06h ;Deshabilita demux 1 y habilita demux 2
movlw 0Ah
movwf 05h
call delay
movlw 09h
movwf 05h
call delay
movlw 0Bh
movwf 05h
call delay
movlw 88h
movwf 05h
call delay
movlw 8Ah
movwf 05h
call delay
movlw 89h
movwf 05h
call delay
movlw 8Bh
movwf 05h
call delay
movlw 08h
movwf 05h
call delay






movlw 08h ;Deshabilita
movwf 06h  ;demux y envía la señal
movlw 4Ch  ;para el siguiente 16F628A
movwf 05h
call delay2
wait
btfss 06h,04h ;espera la señal de la siguiente
goto wait     ;tarjeta controladora
goto init1
;====================================
;Secuencia para la segunda rutina de movimientos.
;====================================
move2


wait1
btfss 06h,04h ;espera bit de confirmación
goto wait1    ;de la segunda tarjeta controladora
movlw 08h
movwf 06h
movlw 4Ch
movwf 05h
movlw 0Fh
movwf 27h
;====================================
;En esta parte del programa se describe un ciclo
;anidado para lograr hacer el efecto de todos
;los LEDs encendidos, ya que el 74LS138 solo
;nos permite el encendido de un LED a la vez
;====================================


move2.1
movlw 11h
movwf 25h
ret1
movlw 0FFh
movwf 26h
ret2
movlw 0Ch
movwf 05h
movlw 00h
movwf 06h
movlw 04h
movwf 06h
movlw 02h
movwf 06h
movlw 06h
movwf 06h
movlw 01h
movwf 06h
movlw 05h
movwf 06h
movlw 03h
movwf 06h
movlw 07h
movwf 06h
movlw 08h
movwf 06h
movlw 0Ah
movwf 05h
movlw 09h
movwf 05h
movlw 0Bh
movwf 05h
movlw 88h
movwf 05h
movlw 8Ah
movwf 05h
movlw 89h
movwf 05h
movlw 8Bh
movwf 05h
movlw 08h
movwf 05h
decfsz 26h,01h
goto ret2
decfsz 25h,01h
goto ret1


;====================================
;En esta parte del programa se describe
;otro ciclo anidado, esta vez para apagar
;todos los LEDs. Combinado con lo anterior
;tendremos como resultado un parpadeo
;prolongado de los LEDs de las barras
;====================================


movlw 11h
movwf 25h
ret3
movlw 0FFh
movwf 26h
ret4
movlw 0FFh
movwf 06h
movwf 05h
decfsz 26h,01h
goto ret4
decfsz 25h,01h
goto ret3


decfsz 27h,01h
goto move2.1


wait2
btfss 06h,04h
goto wait2




movlw 03h
movwf 25h
init2
decfsz 25h,01h
goto move3
goto move4
;====================================
;Tercera secuencia de las barras de LEDs,
;de un lado al otro de la barra pero en
;sentido opuesto.
;====================================
move3
movlw 08h
movwf 06h ;Deshabilita demux 1 y 3 habilita demux 2
movlw 08h
movwf 05h
call delay
movlw 08Bh
movwf 05h
call delay
movlw 89h
movwf 05h
call delay
movlw 8Ah
movwf 05h
call delay
movlw 88h
movwf 05h
call delay
movlw 0Bh
movwf 05h
call delay
movlw 09h
movwf 05h
call delay
movlw 0Ah
movwf 05h
call delay


movlw 0Ch
movwf 05h
movlw 07h
movwf 06h
call delay
movlw 03h
movwf 06h
call delay
movlw 05h
movwf 06h
call delay
movlw 01h
movwf 06h
call delay
movlw 06h
movwf 06h
call delay
movlw 02h
movwf 06h
call delay
movlw 04h
movwf 06h
call delay
movlw 00h
movwf 06h
call delay


movlw 08h
movwf 06h


movlw 4Ch
movwf 05h
call delay2
wait3
btfss 06h,04h
goto wait3
goto init2
;====================================
;Última rutina de parpadeo de los
;LEDs como la mencionada anteriormente
;====================================
move4
movlw 08h
movwf 06h


movlw 4Ch
movwf 05h
call delay2
wait4
btfss 06h,04h
goto wait4


movlw 0Fh
movwf 27h
move4.1
movlw 11h
movwf 25h
ret5
movlw 0FFh
movwf 26h
ret6
movlw 0Ch
movwf 05h
movlw 00h
movwf 06h
movlw 04h
movwf 06h
movlw 02h
movwf 06h
movlw 06h
movwf 06h
movlw 01h
movwf 06h
movlw 05h
movwf 06h
movlw 03h
movwf 06h
movlw 07h
movwf 06h
movlw 08h
movwf 06h
movlw 0Ah
movwf 05h
movlw 09h
movwf 05h
movlw 0Bh
movwf 05h
movlw 88h
movwf 05h
movlw 8Ah
movwf 05h
movlw 89h
movwf 05h
movlw 8Bh
movwf 05h
movlw 08h
movwf 05h
decfsz 26h,01h
goto ret6
decfsz 25h,01h
goto ret5


movlw 11h
movwf 25h
ret7
movlw 0FFh
movwf 26h
ret8
movlw 0FFh
movwf 06h
movwf 05h
decfsz 26h,01h
goto ret8
decfsz 25h,01h
goto ret7


decfsz 27h,01h
goto move4.1


goto start ;vuelve al inicio de la primera rutina




;============================
;GP DELAY
;============================
delay
movlw 0CFh
movwf 020h
w6
movlw 0ffh
movwf 021h
w7
decfsz 021h, 01h
goto w7
decfsz 020h, 01h
goto w6
return


delay2
movlw 01h
movwf 020h
w8
movlw 0ffh
movwf 021h
w9
decfsz 021h, 01h
goto w9
decfsz 020h, 01h
goto w8
return
end
























;==========================
;Programa para la segunda
;tablilla de control de la
;parte uno del proyecto
;==========================
list p=16F628A
movlw 00h
movwf 0Bh
clrf 05h ;secuencia para deshabilitar
movlw 07h ;operaciones de comparación en PORTA
movwf 1Fh ;y habilitar funciones I/O




bsf 03h,05h ;entrar al Banco1
movlw 08h ;configurar el oscilador interno en 4MHz
movwf 8Eh ;enviando 08h al registro PCON(8Eh)
movlw 10h ;configurar las entradas y salidas del PORTB
movwf 86h ;desde TRISB
movlw 00h ;configurar todos los pines de PORTA
movwf 85h ;como salidas
bcf 03h,05h ;salir del Banco1


movlw 0FFh
movwf 05h
movwf 06h


start
movlw 03h
movwf 25h
wait
btfss 06h,04h ;espera el bit de confirmación de la
goto wait     ;primera tablilla de control
;====================================
;Secuencia para la primera rutina de movimiento
;de las barras de LEDs de un lado al otro de la barra
;====================================
init1
decfsz 25h,01h
goto move1
goto move2
move1


movlw 0Ch
movwf 05h ;Deshabilita demux 2
movlw 07h ; habilita demux1
movwf 06h
call delay
movlw 03h
movwf 06h
call delay
movlw 05h
movwf 06h
call delay
movlw 01h
movwf 06h
call delay
movlw 06h
movwf 06h
call delay
movlw 02h
movwf 06h
call delay
movlw 04h
movwf 06h
call delay
movlw 00h
movwf 06h
call delay




movlw 08h
movwf 06h ;Deshabilita demux 1 y habilita demux 2
movlw 08h
movwf 05h
call delay
movlw 08Bh
movwf 05h
call delay
movlw 89h
movwf 05h
call delay
movlw 8Ah
movwf 05h
call delay
movlw 88h
movwf 05h
call delay
movlw 0Bh
movwf 05h
call delay
movlw 09h
movwf 05h
call delay
movlw 0Ah
movwf 05h
call delay






movlw 08h ;Deshabilita
movwf 06h  ;demux 1y 2 y envia la señal
movlw 4Ch ;para el siguiente 16F628A
movwf 05h
call delay2
wait1
btfss 06h,04h ;espera el bit de confirmación
goto wait1    ;de la primera tablilla de control
goto init1


move2
movlw 08h
movwf 06h


movlw 4Ch
movwf 05h
call delay2
wait2
btfss 06h,04h
goto wait2


movlw 0Fh
movwf 27h


;====================================
;Secuencia para la segunda rutina de movimientos.
;====================================
move2.1
movlw 11h
movwf 25h
ret1
movlw 0FFh
movwf 26h
ret2
movlw 0Ch
movwf 05h
movlw 00h
movwf 06h
movlw 04h
movwf 06h
movlw 02h
movwf 06h
movlw 06h
movwf 06h
movlw 01h
movwf 06h
movlw 05h
movwf 06h
movlw 03h
movwf 06h
movlw 07h
movwf 06h
movlw 08h
movwf 06h
movlw 0Ah
movwf 05h
movlw 09h
movwf 05h
movlw 0Bh
movwf 05h
movlw 88h
movwf 05h
movlw 8Ah
movwf 05h
movlw 89h
movwf 05h
movlw 8Bh
movwf 05h
movlw 08h
movwf 05h
decfsz 26h,01h
goto ret2
decfsz 25h,01h
goto ret1


movlw 11h
movwf 25h
ret3
movlw 0FFh
movwf 26h
ret4
movlw 0FFh
movwf 06h
movwf 05h
decfsz 26h,01h
goto ret4
decfsz 25h,01h
goto ret3


decfsz 27h,01h
goto move2.1


movlw 03h
movwf 25h
init2
decfsz 25h,01h
goto move3
goto move4






move3
movlw 08h
movwf 06h ;Deshabilita demux 1 y 3 habilita demux 2
movlw 0Ah
movwf 05h
call delay
movlw 09h
movwf 05h
call delay
movlw 0Bh
movwf 05h
call delay
movlw 88h
movwf 05h
call delay
movlw 8Ah
movwf 05h
call delay
movlw 89h
movwf 05h
call delay
movlw 8Bh
movwf 05h
call delay
movlw 08h
movwf 05h
call delay


movlw 0Ch
movwf 05h ;Deshabilita demux 2  habilita   movlw 00h ;demux 1
movwf 06h
call delay
movlw 04h
movwf 06h
call delay
movlw 02h
movwf 06h
call delay
movlw 06h
movwf 06h
call delay
movlw 01h
movwf 06h
call delay
movlw 05h
movwf 06h
call delay
movlw 03h
movwf 06h
call delay
movlw 07h
movwf 06h
call delay


movlw 08h
movwf 06h
movlw 4Ch
movwf 05h
call delay2


wait3
btfss 06h,04h
goto wait3
goto init2


move4


wait4
btfss 06h,04h
goto wait4
movlw 08h
movwf 06h
movlw 4Ch
movwf 05h


movlw 0Fh
movwf 27h


move4.1
movlw 11h
movwf 25h
ret5
movlw 0FFh
movwf 26h
ret6
movlw 0Ch
movwf 05h
movlw 00h
movwf 06h
movlw 04h
movwf 06h
movlw 02h
movwf 06h
movlw 06h
movwf 06h
movlw 01h
movwf 06h
movlw 05h
movwf 06h
movlw 03h
movwf 06h
movlw 07h
movwf 06h
movlw 08h
movwf 06h
movlw 0Ah
movwf 05h
movlw 09h
movwf 05h
movlw 0Bh
movwf 05h
movlw 88h
movwf 05h
movlw 8Ah
movwf 05h
movlw 89h
movwf 05h
movlw 8Bh
movwf 05h
movlw 08h
movwf 05h
decfsz 26h,01h
goto ret6
decfsz 25h,01h
goto ret5


movlw 11h
movwf 25h
ret7
movlw 0FFh
movwf 26h
ret8
movlw 0FFh
movwf 06h
movwf 05h
decfsz 26h,01h
goto ret8
decfsz 25h,01h
goto ret7
decfsz 27h,01h
goto move4.1
goto start




;============================
;GP DELAY
;============================
delay
movlw 0CFh
movwf 020h
w6
movlw 0ffh
movwf 021h
w7
decfsz 021h, 01h
goto w7
decfsz 020h, 01h
goto w6
return


delay2
movlw 01h
movwf 020h
w8
movlw 0ffh
movwf 021h
w9
decfsz 021h, 01h
goto w9
decfsz 020h, 01h
goto w8
return
end