You are on page 1of 8

FRECUENCIMETRO Desarrollar un frecuencmetro utilizando el Tmr0 como temporizador para una base de tiempo de 1 segundo y el Tmr1 como contador

de eventos.

DIAGRAMA DE FLUJO
FRECUENCIMETRO

Configuraciones: LCD OPTION_REG=0X07 TRISB =0X03 INTCON=0X07


Letrero1 rengln

Posicionar en 2 rengln
display Letrero 2 rengln T1CON=0X06

T1=ON
1 SEGUNDO T1=OFF CONVERTIR EXHIBIR

PROGRAMA letrero_1 letrero_2 e rs respaldo_w respaldo_pb apuntador contador cont_1 cont_2 cont_int U dece cent M DM contador_48 geie t1on toif toie

equ equ

equ equ equ equ

equ

equ

inicio:

0x00 0x10 equ 0x02 equ 0x03 0x20 0x21 0x22 0x23 equ 0x24 equ 0x25 0x26 equ 0x30 equ 0x31 equ 0x32 equ 0x33 equ 0x34 0x35 equ 0x07 equ 0x00 equ 0x02 equ 0x05 org 0x00 goto inicio org 0x04 goto inter_t0 org 0x05 bsf status,rp0 movlw 0x03 movwf trisb movlw 0x07;

configuro para preescala de

256 a tmr0 movwf option_reg; ,flanco de subida,reloj intern bcf status,rp0 bsf intcon,geie; habilito las interrupciones globales call config_lcd movlw letrero_1 call renglon bcf portb,rs movlw 0xc0 call display_4

bsf portb,rs movlw letrero_2 call renglon movlw 0x06; oscilador tmr1,

prescala1:1, apagado el

movwf t1con; ,no sincrono, encendemos el reloj externo(contador de eventos) tt0: bsf t1con,t1on; encendemos el tmr1 call segundo; bcf t1con,t1on; apago el tmr1 clrf U clrf dece clrf cent clrf M clrf DM call convierte_v call exhibir_v goto tt0 inter_t0: bcf intcon,toif; habilito la bandera de tmro (indicador de desbordamiento) movlw 0x9c; 50miliseg movwf tmr0 incf cont_int,f retfie segundo: clrf cont_int bsf intcon,toie; habilito las interrupciones del tmr0 regresa: movlw 0x14; comparo, pregunto, resto un 14(20dec) subwf cont_int,w; con lo q tiene cont_int btfss status,z goto regresa bcf intcon,toie; apago el habilitador de int del tmr0 return config_lcd: bcf portb,rs movlw 0x23 call display_4 movlw 0x22 call display_4 movlw 0x28 call display_4 movlw 0x0c

display_4:

movwf

call display_4 bsf portb,rs return respaldo_w; movfw portb; andlw 0x0f; movwf respaldo_pb; movfw respaldo_w; andlw 0xf0; iorwf respaldo_pb,w; movwf portb; bsf portb,e; call retardo; bcf portb,e; swapf respaldo_w,w; andlw 0xf0; iorwf respaldo_pb,w; movwf portb; bsf portb,e; call retardo; bcf portb,e; return apuntador movlw 0x10 movwf contador apuntador call letreros call display_4 incf apuntador,f decfsz contador,f goto repite_2 return status,rp0 movlw 0x00 subwf tmr1l,w btfss status,z goto inicia_conver bcf status,rp0 movlw 0x00 subwf tmr1h,w

renglon:

movwf

repite_2:

movfw

convierte_v: chkl:

bcf

inicia_conver:

call

chkh:

btfss status,z goto chkh return cuarenta_8 decfsz tmr1l,f goto inicia_conver movlw 0x00 bcf status,rp0 subwf tmr1h,w btfss status,z goto chkh return decf tmr1h,f bcf status,rp0 movlw 0xff movwf tmr1l goto chkl status,rp0 movlw 0x02 movwf contador_48 decf contador_48,f btfsc status,z bsf status,rp0 incf DM,f goto checa movlw 0x0a subwf DM,w btfss status,z goto rc0 clrf DM incf M,f movlw 0x0a subwf M,w btfss status,z goto rc0 clrf M incf cent,f movlw 0x0a subwf cent,w btfss status,z

cuarenta_8:

bcf

rc0:

rc1:

checa:

exhibir_v:

bcf

goto rc0 clrf cent incf dece,f movlw 0x0a subwf dece,w btfss status,z goto rc0 clrf dece incf U,f movlw 0x00 subwf contador_48,w btfss status,z goto rc1 bcf status,rp0 return portb,rs movlw 0xc2 call display_4 bsf portb,rs movfw U addlw 0x30 call display_4 movfw dece addlw 0x30 call display_4 movfw cent addlw 0x30 call display_4 movfw M addlw 0x30 call display_4 movfw DM addlw 0x30 call display_4 return 0xcc movwf movlw movwf decfsz

retardo:

movlw

mas:

cont_2 0xcc cont_1 cont_1,f

goto decfsz goto return org 0xbe pcl,f retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw

mas cont_2,f mas

letreros:

addwf

"" "F" "R" "E" "C" "U" "E" "N" "C" "I" "M" "E" "T" "R" "O" "" "" "" "0" "0" "0" "0" "0" "" "" "" "" "" "" "" "" ""

DIAGRAMA

LCD1
LM016L

5V

VSS VDD VEE

RS RW E 4 5 6
+ -

1 2 3

U1 X1
CRYSTAL 13 14 2 3 4 5 6 7 8 9 10 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

10k

R2
10k

RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A

7 8 9 10 11 12 13 14
FM AM

R1

D0 D1 D2 D3 D4 D5 D6 D7

You might also like