Documentos de Académico
Documentos de Profesional
Documentos de Cultura
PIC 16F877
Sensor de temperatura LM35
Funcionamiento: Programa en lenguaje ensamblador que muestra en un LCD
16x2 la temperatura recibida por el sensor LM35.
+1500mV = 150C
+250mV = 25C
-550mV = -55C
processor 16f877
include<p16f877.inc>
org 0h
goto INICIO
org 05h
INICIO:
clrf PORTA
;Limpia el puerto A
clrf PORTB
;Limpia el puerto B
clrf PORTC
;Limpia el puerto C
clrf PORTD
;Limpia el puerto D
bsf STATUS,RP0
bcf STATUS,RP1
;Cambio al banco 1
clrf TRISD
movlw 3fh
movwf TRISA
movlw h'0'
bcf STATUS,RP0
;Regresa al banco 0
;Inicializa LCD
goto START_ADC
;Inicia LCD
START_LCD:
bcf PORTC,0
movlw 0x01
movwf PORTD
call COMANDO
; Se da de alta el comando
movlw 0x0C
movwf PORTD
call COMANDO
; Se da de alta el comando
movlw 0x3C
; Se configura el cursor
movwf PORTD
call COMANDO
; Se da de alta el comando
bsf PORTC, 0
return
call COMANDO
; Se da de alta el comando
return
call DELAY2
; Tiempo de espera
call DELAY2
bcf PORTC, 1
call DELAY2
return
; ENABLE=0
movlw 0x01
movwf PORTD
call COMANDO
; Se da de alta el comando
bsf PORTC, 0
return
goto ESPERA
movf ADRESH,0
;Si
movwf PORTB
;Limpia LCD
movlw 'T'
movwf PORTD
call ENVIA
movlw '='
movwf PORTD
call ENVIA
call READ_TEMP
movf Centenas,W
movwf PORTD
call ENVIA
movf Decenas,W
movwf PORTD
call ENVIA
movf Unidades,W
movwf PORTD
call ENVIA
movlw ' '
movwf PORTD
call ENVIA
movlw h'DF'
movwf PORTD
call ENVIA
movlw 'C'
movwf PORTD
call ENVIA
goto CICLO
READ_TEMP:
clrf Centenas
clrf Decenas
clrf Unidades
movf ADRESH,W
addwf ADRESH,W
;W=d'100'
subwf Resto,W
btfss STATUS,C
goto DECENAS1
;SI
movwf Resto
incf Centenas,1
goto CENTENAS1
DECENAS1
movlw d'10'
;W=d'10'
subwf Resto,W
btfss STATUS,C
goto UNIDADES1
;Si
movwf Resto
incf Decenas,1
goto DECENAS1
UNIDADES1
movf Resto,W
movwf Unidades
;clrf Resto
decfsz val,1
goto Loop
return