domingo, 23 de junio de 2013

Cuarto tutorial de programacion PIC en asembler, Prender y apagar un led con el mismo pulsador




código del ejemplo
recuerde copiar la librería retardos en la misma carpeta donde esta el archivo del pic.

list p=16f877A
INCLUDE

__config _CP_OFF&_CPD_OFF&_LVP_OFF&_WDT_OFF&_XT_OSC

cblock 0x20
endc

#define PULSA1 PORTA,0
#DEFINE LED1   PORTC,0
ORG 0


BSF STATUS,RP0 ;BANCO UNO CONFIGURACIONES
BSF PULSA1
BCF LED1
MOVLW 0X06
MOVWF ADCON1 ;COLOCA EN DIGITAL LOS PINES 
BCF STATUS,RP0 ;BANCO CERO ACCIONES

BCF LED1
BSF PULSA1

VERIFICA BTFSC PULSA1
GOTO VERIFICA ; SALTA SI ES UNO
CALL Retardo_10ms; salta por que es cero presiono
BTFSS PULSA1
goto VERIFICA 
MOVLW B'00000001'
XORWF PORTC,F
goto VERIFICA

INCLUDE
END

No hay comentarios: