Termometro pic
#include "p16F877.inc" ; incluyendo la definicicion
; de registros internos
; de la libreria
;DEFINIENDO VARIABLESconteo equ 0x20
temp_w equ 0x21
temp_s equ 0x22
hex1 equ 0x25
hex2 equ 0x26
var1 equ 0x27
var2 equ 0x28
var3 equ 0x29
;------------------------------------------------;-------------------------------------------------
org 0x00 ; MASTER CLEAR RESET
goto inicio
org 0x04 ; VECTOR DE INTERRUPCIONES
goto interrupcionorg 0x05
;-------------------------------------------------
; SUBRUTINA DE INTERRUPCION (TIMER)
;-------------------------------------------------
interrupcion
BANKSEL INTCONbcf INTCON,GIE ; disable all INTERRUPTS
; guardando parametros ( w, status)
movwf temp_w ; guardando el acumulador
swapf STATUS,W ; W=reg(status)
movwf temp_s ;guardando registro status
;..........................................................................
BANKSEL ADRESL
movf ADRESL,W ;w=ADRESL (DATO ADC )
BANKSEL hex1
movwfhex1
call convertir
BANKSEL PORTB
movwf PORTB ; Desplegando el dato OBTENIDO por el puerto B
; restaurando parametros ( w, status)
swapf temp_s,W ; w= statusmovwf STATUS ; status = acumulador
swapf temp_w,W ; restaurando valor original de acumulador
BANKSEL PIR1 ; ver pag(35)
bcf PIR1,ADIF ; habilitando banderaTIMER1 para otra interrupcion
BANKSEL INTCON ; ver pag(32)
bsf INTCON,GIE ; enable global interrupts
retfie
convertir
BANKSEL hex1
clrf var3
movlw .10 ;Verificaque el valor a transformar sea menor a 10
subwf hex1,W ;de lo contrario existe un error al llevar a decimal
btfss STATUS,C
goto fin
movlw .10
movwf var2
movf hex1,W
movwf var1
otra...
Regístrate para leer el documento completo.