You are on page 1of 3

Control en Biosistemas: Cdigo de Entrenamiento

;---------------------------------------------------------------------------------------------------------------------------;Control en Biosistemas con Lgica Contnua


;
;Programa de encendido de un led controlado por pulsador. Un slo pulsador
enciende y apaga el led
;---------------------------------------------------------------------------------------------------------------------------list p=18F4550
include <p18F4550.inc>
;
include <Configuration Bits.txt>
;---------------------------------------------------------------------------------------------------------------------------;Defining Special Bits
;---------------------------------------------------------------------------------------------------------------------------STATUSLED
EQU
2
PUSHBUTTON
EQU 1
LED
EQU 4
;---------------------------------------------------------------------------------------------------------------------------;Defining General Registers (GPR)
;---------------------------------------------------------------------------------------------------------------------------CBLOCK 0x00
TEST
ENDC
;---------------------------------------------------------------------------------------------------------------------------ORG
00
GOTO
Start
;---------------------------------------------------------------------------------------------------------------------------;Main Program
;---------------------------------------------------------------------------------------------------------------------------Start
CALL

CONFIGURATION

;Configuration routine

MAIN

;starts main program


BSF
PORTA,STATUSLED
;Turn on Status led
A1
BTFSS
PORTA,PUSHBUTTON
;Ask if pushbutton is
pressed TO TURN ON LED
GOTO
A1
;No, then
loop
A2
BTFSC
PORTA,PUSHBUTTON
;Yes, then ask if
pushbutton is released
GOTO
A2
;No, then loop
BSF
PORTB,LED
;Yes, then turn on Led
A3
BTFSS
PORTA,PUSHBUTTON
;Ask if pushbutton is
pressed TO TURN OFF LED
GOTO
A3
;No, then loop
A4
BTFSC
PORTA,PUSHBUTTON
;Yes, then ask if
pushbutton is released
GOTO
A4
;No, then loop
BCF
PORTB,LED
;Yes, then turn off led
GOTO
MAIN
;Continue
CONFIGURATION
;---------------------------------------------------------------------------------------------------------------------------;Configuring Special Registers (SFR)
;---------------------------------------------------------------------------------------------------------------------------CLRF
CLRF
CLRF
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
CLRF
CLRF

PORTA
PORTB
PORTC
B'00000010'
TRISA
B'00000000'
TRISB
B'00000000'
TRISC
B'00001111'
ADCON1
B'10000000'
OSCTUNE
B'01101111'
OSCCON
UCON
UCFG

;RA1 inputs, others ouput


;PORTB all outputs

;All digital
;Internal clock, 4 MHz

RETURN
END

ing. edgar gmez acero

You might also like