; AUTOR: JUANCHOPOLO
; FILE: C:FINAL.ASM
; VERSION: XXXXXXXXXXXXXXXXXXXXXXXXXX
; FECHA INICIO: XXXXXXXXXXXXXXXXXXXXXX
; FECHA FINA: XXXXXXXXXXXXXXXXXXXXXX
; DRSCRIPCION: XX XXXXXXXXX XXXXXXXXX XXXXXXXXXXXX XXXXXXXXXX XXXXXXXXX XXXXXXXX
;
;
;*****************************************
TITLE "GRUA"
LIST P= 16F887
#include <p16f887.inc>
errorlevel -302
;*****************************************
;*****************************************
;BIT DE CONFIGURACION
__CONFIG _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF
;*****************************************
STATUS EQU 03
PORTA EQU 05
PORTB EQU 06
PORTC EQU 07
PORTD EQU 08
PORTE EQU 09
TRISA EQU 0X85
TRISB EQU 0X86
TRISC EQU 0X87
TRISD EQU 0X88
TRISE EQU 0X89
WPUB EQU 0X95
ANSEL EQU 0X188
ANSELH EQU 0X189
OSCOON EQU 0X8F
OSCTUNE EQU 0X90
PSTRCON EQU 0X9D
;*****************************************
;VARIABLES
VAR01 EQU 20
VAR02 EQU 21
VAR03 EQU 22
CONT EQU 23
TECLA1 EQU 24
TECLA2 EQU 25
TECLA3 EQU 26
TECLA4 EQU 27
;*****************************************
ORG 0X00
GOTO INICIO
;*****************************************
; ZONA PROHIBIDA ¡
;******************************************
ORG 0X30
INICIO
;*****************************************
CALL CONFIG_PORTD
CALL CONFIG_PORTC
BCF STATUS,0X05
MOVLW 0X3F
MOVWF PORTC
CALL DELAY_5S
LEE_TECLA1:
MOVF PORTD,0 ;--> W = PORTB (LEE)
ANDLW 0X01
MOVWF TECLA1
BTFSS TECLA1,0
GOTO LEE_TECLA2
MOVLW 0X76
MOVWF PORTC
CALL DELAY_5S
MOVLW 0X3E
MOVWF PORTC
CALL DELAY_5S
GOTO LEE_TECLA1
LEE_TECLA2:
MOVF PORTD,0 ;--> W = PORTB (LEE)
ANDLW 0X02
MOVWF TECLA2
BTFSS TECLA2,1
GOTO LEE_TECLA1
MOVLW 0X6D
MOVWF PORTC
CALL DELAY_5S
MOVLW 0X5B
MOVWF PORTC
CALL DELAY_5S
GOTO LEE_TECLA1
;*****************************************
; PUERTO D DE SALIDA
;*****************************************
CONFIG_PORTD
BANKSEL PORTD;
CLRF PORTD ; init PORTD
BANKSEL TRISD
MOVLW 0XFF
MOVWF TRISD
RETURN
;*****************************************
; PUERTO D DE ENTRADA
;*****************************************
CONFIG_PORTC
BANKSEL PORTC;
CLRF PORTC ; init PORTC
BANKSEL TRISC
MOVLW 0X00
MOVWF TRISC
RETURN
;*****************************************
DELAY_5S
MOVLW 0X024
MOVWF VAR01
WWWW MOVLW 0X0A7
MOVWF VAR02
YYYY MOVLW 0X054
MOVWF VAR03
XXXX DECFSZ VAR03,1
GOTO XXXX
DECFSZ VAR02
GOTO YYYY
DECFSZ VAR01
GOTO WWWW
NOP
NOP
RETURN
;******************************************
END