1.- Conocer el lenguaje ensamblador así como las herramientas básicas para programar el microcontrolador PIC16F877A.
Enviado por karlo • 30 de Diciembre de 2017 • 1.359 Palabras (6 Páginas) • 493 Visitas
...
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files Required: P16F877A.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************
list p=16f877A ; list directive to define processor
#include ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving
CounterA EQU 0x7A ;memoria donde lo guarda
CounterB EQU 0x7B ;memoria donde lo guarda
CounterC EQU 0x7C ;memoria donde lo guarda
;**********************************************************************
ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
;Configuracion de puertos
movlw 20H ;cambiamos al banco 1
movwf STATUS ;configurando el puerto como salida
movlw 00H ; ucf status ,5 asi se puede poner
movwf TRISB ; bcf status, asi se puede poner
bsf TRISA,0 ;poner el puerto a en 0
movlw 00H
movwf STATUS
inicio
btfsc PORTA,0
goto modo1
goto modo2
modo1
BSF PORTB,0
CALL DELAY2S
BCF PORTB,0
CALL DELAY2S
CALL DELAY2S
GOTO inicio
modo2
BSF PORTB,0
CALL DELAY1S
BCF PORTB,0
CALL DELAY1S
CALL DELAY1S
GOTO inicio
; remaining code goes here
DELAY2S
;PIC Time Delay = 2,00000200 s with Osc = 4000000 Hz
movlw D'11'
movwf CounterC
movlw D'38'
movwf CounterB
movlw D'93'
movwf CounterA
loop2 decfsz CounterA,1
goto loop2
decfsz CounterB,1
goto loop2
decfsz CounterC,1
goto loop2
retlw 0
DELAY1S
;PIC Time Delay = 0.10000200 s with Osc = 4000000 Hz
movlw D'130'
movwf CounterB
movlw
...