Está en la página 1de 11

ESCUELA SUPERIOR POLITCNICA DEL

LITORAL FACULTAD DE INGENIERIA EN


ELECTRICIDAD Y COMPUTACIN
fiec

LABORATORIO DE
MICROCONTROLADORES
Informe #3:
Subrutinas y pulsadoras
Profesor:
Ing. Vctor Asanza
REALIZADO POR:
Estefania Banchn Len
Maricela Elaje Acevedo

PARALELO:
Fecha de presentacin:
13/05/2014

OBJETIVO:
Comprender

el

uso

de

instrucciones

desplazamiento as como operaciones lgicas.


CONTENIDO:
a) ESPECIFICACIONES PARTE 1
b) CDIGO P3A_RET.ASM
c) ESPECIFICACIONES PARTE 2
d) CDIGO P3B_RET.ASM
e) ANEXO PRCTICA 3

de

PARTE 1

a) ESPECIFICACIONES:
En este ejercicio se realiza el desplazamiento de leds y cuando se
presiona la botonera se detiene el desplazamiento.

b) CDIGO P3A_RA.ASM:
;**********************************************************
;
USO DE SUBRUTINAS Y PULSADORES
;**********************************************************
;
NOMBRE:
p3a_ra.asm
;
FECHA:
14/06/2010
;
VERSION:
1.00
;**********************************************************

LIST
INCLUDE

p=16F887
P16F887.INC

;Tipo de microcontrolador
;Define los SFRs y bits del
;P16F887

__CONFIG _CONFIG1, _CP_OFF&_WDT_OFF&_XT_OSC


;Setea parmetros de
;configuracin
errorlevel

-302

;Deshabilita mensajes de
;advertencia por cambio

;bancos
;***********************************************************************
;
Header
;***********************************************************************
;************* DEFINING VARIABLES **************************************
cblock
counter1
counter2
endc

0x20

;
;
;
;

Block of
Variable
Variable
Block of

variables starts at address 20h


"counter1" at address 20h
"counter2" at address 21h
variables ends

;************************ MAIN PROGRAM *********************************


org
instruction
banksel
clrf
clrf
banksel
clrf

0x00

; Address of the first program

ANSEL
ANSEL
ANSELH

; Selects bank containing register ANSEL


; Clears registers ANSEL and ANSELH to
; configure all inputs as digital

TRISB
TRISB

; Selects bank containing register TRISB


; All port B pins are configured as

outputs
movlw
movwf

B'00000010'
TRISA
; Pin RA1 is input

banksel
movlw
movwf

PORTB
; Selects bank containing register TRISB
B'00000001'
; Writes 1 to register W
PORTB
; Number is moved to PORTB

rlf
call

PORTB,f
DELAY

; Port B bits rotates by one place left


; Calls subroutine "DELAY"

btfss
goto

PORTA,1
loop3

; Tests the firs port A bit


; "0" is applied to pin.Go to label

loop

; "1" is applied to pin.Go to label "loop"

loop
loop3
"loop3"
goto

;************************ SUBROUTINES **********************************


DELAY
clrf
counter2
; Clears variable "counter2"
loop1
clrf
counter1
; Clears variable "counter1"
loop2
decfsz
counter1
; Decrements variable "counter1" by 1
goto
loop2
; Result is not 0. Go to label loop2
decfsz
counter2
; Decrements variable "counter2" by 1
goto
loop1
; Result is not 0. Go to lab loop1
return
; Return from subroutine "DELAY"
End

; End of program

PARTE 2

c) ESPECIFICACIONES:

En

esta

parte

de

la

prctica

se

har

uso

itch para modificar la ejecucin del programa.

d) CDIGO P3B_RA.ASM:
;*********************************************************
;DESPLAZAMIENTO DE LEDS
;*********************************************************
;
NOMBRE:
p3b_ret.asm
;
FECHA:
31/05/2010

de

un

sw

;
VERSION:
1.00
;*********************************************************
LIST
INCLUDE

p=16F887
P16F887.INC

;Tipo de microcontrolador
;Define los SFRs y bits del
;P16F887

__CONFIG _CONFIG1, _CP_OFF&_WDT_OFF&_XT_OSC


;Setea parmetros de
;configuracin
errorlevel

-302 ;Deshabilita mensajes de


;advertencia por cambio bancos
;*********************************************************
;DEFINICION DE VARIABLES
; Las variables en el 16F887 pueden escribirse a partir de la
; posicin de memoria de datos 0x20
cblock

0x20

;Bloque de variables empieza en la


; direccin 20h
; Variable "counter" en direccin 20h

counter1
counter2
counter3
endc
;********************************************************
;INICIO DEL PROGRAMA
org
0x00

; Direccin de la primera instruccin

;SETEO DE PUERTOS
banksel
clrf
clrf
banksel
clrf
clrf
clrf
bsf
banksel

ANSEL
ANSEL
ANSELH
TRISB
TRISB
TRISC
TRISD
TRISA,0
PORTB
; selecciona banco que contiene

;INICIALIZACION DE VARIABLES
clrf
PORTB
clrf
PORTC
clrf
PORTD
clrf
counter1
bcf
STATUS,0
;DESARROLLO DEL PROGRAMA
inicio
btfss
goto

PORTA,0
sube

movlw
movwf
movwf
movlw
movwf

0x10
PORTB
PORTD
0x3C
PORTC

rlf
movf
andlw
iorwf
bcf
rlf

PORTB,f
STATUS,W
0x01
PORTB,f
STATUS,0
PORTC,f

baja

baja2

movf
andlw
iorwf
bcf
rlf
movf
andlw
iorwf
bcf
call
btfsc
goto

STATUS,W
0x01
PORTC,f
STATUS,0
PORTD,f
STATUS,W
0x01
PORTD,f
STATUS,0
DELAY2
PORTA,0
baja2

movlw
movwf
movwf
movlw
movwf

0x08
PORTB
PORTD
0x3C
PORTC

rrf
swapf
andlw
addlw
andlw
iorwf
bcf
rrf
swapf
andlw
addlw
andlw
iorwf
bcf
rrf
swapf
andlw
addlw
andlw
iorwf
bcf
call
btfss
goto
goto

PORTB,f
STATUS,w
0x10
0x70
0x80
PORTB,f
STATUS,0
PORTC,f
STATUS,w
0x10
0x70
0x80
PORTC,f
STATUS,0
PORTD,f
STATUS,w
0x10
0x70
0x80
PORTD,f
STATUS,0
DELAY2
PORTA,0
sube2
baja

movlw
movwf

.10
counter3

movlw
movwf

.57
counter2

movlw
movwf

.57
counter1

decfsz

counter1

goto

loop5

decfsz

counter2

sube

sube2

DELAY2
loop3
loop4
loop5
; Decrements variable "counter1"

by 1
; Result is not 0. Go to label

loop5
; Decrements variable "counter2" by

1
goto
loop4
; Result is not 0. Go to lab loop4
decfsz
counter3
goto
loop3
return
; Return from subroutine "DELAY2"
;********************************************************************

end
; Fin del programa
;*****************************************************

ANEXO DE RESPUESTAS A PRCTICA 3

INTEGRANTE 1: ______________________________
INTEGRANTE 2: ______________________________
PARALELO: _____

GRUPO: _____

RESPONDER

1)

Modifique el programa de la parte 1 colocando un interruptor


en RA1 en lugar del pulsador, de tal forma que con el
interruptor se pueda cambiar la direccin de giro de los leds.

2)

Modifique el programa de la parte 2 de tal forma que cuando


se cierre el interruptor se muestre una de las iniciales de los
integrantes del grupo y se desplace hacia abajo. Cuando se
abra el interruptor se muestra la inicial del otro integrante del
grupo desplazando hacia arriba.

También podría gustarte