;8 PULSADORES PARA CONCURSOS DE VELOCIDAD DE TELEVISION ; º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º ; º | | | | | | | | | | | | º ; º _|__|__|__|__|__|__|__|__|__|__|__|_ _\\|//_ Jose º ; º | | (| o-o |) Martinez º ; º | www.microcontroladorespic.com | \ (_) / Ortiz º ; º |) | \_"_/ º ; º | 8 pulsadores para concursos de TV | __|U|__ º ; º | 16f628A | / \ º ; º |_ __ __ __ __ __ __ __ __ __ __ __ _| / /| |\ \ º ; º | | | | | | | | | | | | / / | | \ \ º ; º | | | | | | | | | | | | "" |___| "" º ; º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º º ; DESCRIPCION ;Dispone de 8 pulsadores con 8 salidas, de modo que solo el pulsador que ;primero se actue conseguira actuar su salida correspondiente. ;Los pulsadores que se actuen a continuacion no actuaran de ninguna forma ;************************ BITS DE CONFIGURACION ************************* ;CP_OFF - Codigo de proteccion programa desactivado ;CPD_OFF - Codigo de proteccion eeprom desactivado ;WDT_OFF - Perro guardian desconectado ;BODEN_OFF - No actua el reset por bajada de tension ;PWRTE_OFF - Reset de inicio desconectado ;MCLRE_OFF - Reset externo desconectado, sino pierdo una entrada A5 ;XT_OSC - oscilador exterior ;INTOSC_OSC_NOCLKOUT - funcionamiento con reloj interno ;LVP_OFF - programacion de bajo voltage desconectado, ; para activar el pin 4 de RB __CONFIG _LVP_OFF & _MCLRE_OFF & _BODEN_OFF & _CP_OFF & _PWRTE_ON & _WDT_ON & _INTOSC_OSC_NOCLKOUT LIST P=16F628A ;Procesador utilizado. INCLUDE ERRORLEVEL 0, -302 ;suppress bank selection messages ;****************************** ZONA DE DATOS **************************** #define Banco0 bcf STATUS,RP0 #define Banco1 bsf STATUS,RP0 #define Led_1 PORTA,6 #define Led_2 PORTA,7 #define Led_3 PORTA,0 #define Led_4 PORTA,1 #define Led_5 PORTA,2 #define Led_6 PORTA,3 #define Led_7 PORTB,0 #define Led_8 PORTB,1 #define Pulsador_1 PORTA,5 #define Pulsador_2 PORTB,7 #define Pulsador_3 PORTB,6 #define Pulsador_4 PORTB,5 #define Pulsador_5 PORTB,4 #define Pulsador_6 PORTB,3 #define Pulsador_7 PORTB,2 #define Pulsador_8 PORTA,4 ;****************************** MAPA DE MEMORIA **************************** CBLOCK 0x20 ;Inicio de 16f628, pero 0C para el 16f84 PDel0 PDel1 PDel2 ENDC ;****************************************************************************** ;************************* INICIO **************************** ;****************************************************************************** Inicio org 0 goto Configuracion ;Datos que se veran al cargar el HEX en el micro, pero no afectan al programa DT " Pulsadores para concursos televisivos" DT " 16f628A" Configuracion Banco1 ;Acceso al Banco 1. bsf Pulsador_1 ;entradas bsf Pulsador_2 bsf Pulsador_3 bsf Pulsador_4 bsf Pulsador_5 bsf Pulsador_6 bsf Pulsador_7 bsf Pulsador_8 bcf Led_1 ;salidas bcf Led_2 bcf Led_3 bcf Led_4 bcf Led_5 bcf Led_6 bcf Led_7 bcf Led_8 bcf OPTION_REG,NOT_RBPU ;Activa las resistencias Pull-Up del Puerto B Banco0 ;Acceso al Banco 0. movlw 0x07 ;desconecta los comparadores analogicos del movwf CMCON ;pic 16f628 call Apago ;apaga todos los led ;****************************************************************************** ;********************* PULSADORES ****************** ;****************************************************************************** Ver_Pulsadores clrwdt btfss Pulsador_1 ;salta si no esta presionado goto Prende_1 ;actua sobre el led btfss Pulsador_2 ;salta si no esta presionado goto Prende_2 ;actua sobre el led btfss Pulsador_3 ;salta si no esta presionado goto Prende_3 ;actua sobre el led btfss Pulsador_4 ;salta si no esta presionado goto Prende_4 ;actua sobre el led btfss Pulsador_5 ;salta si no esta presionado goto Prende_5 ;actua sobre el led btfss Pulsador_6 ;salta si no esta presionado goto Prende_6 ;actua sobre el led btfss Pulsador_7 ;salta si no esta presionado goto Prende_7 ;actua sobre el led btfss Pulsador_8 ;salta si no esta presionado goto Prende_8 ;actua sobre el led goto Ver_Pulsadores ;****************************************************************************** ;********************* ENCENDER y APAGAR LED ********************* ;****************************************************************************** Prende_1 bsf Led_1 goto Final Prende_2 bsf Led_2 goto Final Prende_3 bsf Led_3 goto Final Prende_4 bsf Led_4 goto Final Prende_5 bsf Led_5 goto Final Prende_6 bsf Led_6 goto Final Prende_7 bsf Led_7 goto Final Prende_8 bsf Led_8 goto Final Final call DEMORA_10seg call Apago goto Ver_Pulsadores Apago ;todas las salidas desconectadas bcf Led_1 bcf Led_2 bcf Led_3 bcf Led_4 bcf Led_5 bcf Led_6 bcf Led_7 bcf Led_8 RETURN ;****************************************************************************** ;************************* RETARDOS **************************** ;****************************************************************************** ; Descripcion: Delay 10000000 ciclos DEMORA_10seg movlw .43 ; 1 set numero de repeticion (C) movwf PDel0 ; 1 | PLoop0 movlw .226 ; 1 set numero de repeticion (B) movwf PDel1 ; 1 | PLoop1 movlw .205 ; 1 set numero de repeticion (A) movwf PDel2 ; 1 | PLoop2 clrwdt ; 1 clear watchdog clrwdt ; 1 ciclo delay decfsz PDel2, 1 ; 1 + (1) es el tiempo 0 ? (A) goto PLoop2 ; 2 no, loop decfsz PDel1, 1 ; 1 + (1) es el tiempo 0 ? (B) goto PLoop1 ; 2 no, loop decfsz PDel0, 1 ; 1 + (1) es el tiempo 0 ? (C) goto PLoop0 ; 2 no, loop clrwdt ; 1 ciclo delay return ; 2+2 Fin. end