Skip to content

Instantly share code, notes, and snippets.

@charliexr
Created December 22, 2010 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charliexr/752087 to your computer and use it in GitHub Desktop.
Save charliexr/752087 to your computer and use it in GitHub Desktop.
Leds y Switch - para simular en GPSim
;
;Parpadea uno u otro LED de acuerdo al estado de un switch
;PIC16F628A
;22/12/2010
;http://charliexray.blogspot.com
;
;Para simular con gpsim. No fue probado en la practica.
;
;========================================================================
;PIC a utilizar
;========================================================================
list p = 16F628A
#include <p16F628A.inc>
;========================================================================
;configuracion de fusibles
;========================================================================
__CONFIG _WDT_OFF & _PWRTE_OFF & _INTOSC_OSC_NOCLKOUT & _MCLRE_OFF & _BOREN_ON & _LVP_OFF & _DATA_CP_OFF & _CP_OFF
;========================================================================
;reserva de registros en memoria
;========================================================================
;contador equ 0x21 ;un contador
ORG 0x00 ;inicio luego de un reset
;========================================================================
;definiciones mnemotecnicas
;========================================================================
#define led0 PORTA,0 ;led0 conectado al pin 0 del puerto A
#define led1 PORTA,1
#define switch PORTB,0 ;switch conectado al pin 0 del puerto B
;========================================================================
;configuracion de registros
;========================================================================
;me paso al banco1
bcf STATUS,RP1
bsf STATUS,RP0
clrf TRISA ;puerto A como salida
bsf TRISB,0 ;pin 0 del puerto B como entrada
;vuelvo al banco0
bcf STATUS,RP1
bcf STATUS,RP0
;deshabilito comparadores analogicos
movlw 0x07
movwf CMCON
;========================================================================
;Programa Principal
;========================================================================
ppal ;programa principal
clrf PORTA ;apago los dos leds
btfss switch ;si switch = 1, me salto la siguiente linea
bsf led0 ;switch=0 > enciendo led0
btfsc switch ;si switch = 0, me salto la siguiente linea
bsf led1 ;switch=1 > enciendo led1
goto ppal ;regreso a ppal
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment