您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机PIC16F84单片机做的频率计 正文
PIC16F84单片机做的频率计

PIC16F84单片机做的频率计

点击数:7161 次   录入时间:03-04 11:43:15   整理:http://www.55dianzi.com   PIC单片机

        call    init_LCD        ; Contains function set & clear screen.
        call    dsp_fixmsg        ; Display fixed message.

;    *** Main Loop ***

mainloop
        call    set_cntmode        ; Set count mode. (Gate time etc.)
        call    dsp_status        ; Display status.

         MOV f    DSPMODE, f        ; Check display mode.
        btfss    status, z        ;
        goto    len_mode        ;

        call    dsp_freq        ; Display frequency.
        goto    cntstart
len_mode
        call    dsp_leng        ; Display wave length.
cntstart
        call    dsp_goff        ; Display "Gate OFF".
        call    dsp_gon            ; Display "Gate ON".
        call    count            ; Count core.

        goto    mainloop

;-------------------------------------------------------------------------
; Set count mode.
;   Input : Port B   (Data input port of count mode)
;   Output: DSPMODE  (Display mode)
;           EXT_PSC  (External prescaler mode)
;           INT_PSC  (Internal prescaler mode)
;           RESMODE  (Resolution mode)
;           GATETIME (Gate time in milliseconds)
;           W register & variable I will be broken.
;
;   Notes: All input ports are negative logic.
;-------------------------------------------------------------------------

set_cntmode

;    *** Get count mode from input port ***

         MOV f    portb, w        ; Read input port &
        andlw    00111111b        ; negate logic.
        xorlw    00111111b        ;
         MOV wf    CNTMODE            ;

        andlw    00000011b        ; Get resolution mode.
         MOV wf    RESMODE            ;

        rrf    CNTMODE, f        ; Get internal prescaler mode.
        rrf    CNTMODE, f        ;
         MOV f    CNTMODE, w        ;
        andlw    00000011b        ;
         MOV wf    INT_PSC            ;

        rrf    CNTMODE, f        ; Get external prescaler mode.
        rrf    CNTMODE, f        ;
         MOV f    CNTMODE, w        ;
        andlw    00000001b        ;
         MOV wf    EXT_PSC            ;

        rrf    CNTMODE, f        ; Get display mode.
         MOV f    CNTMODE, w        ;
        andlw    00000001b        ;
         MOV wf    DSPMODE            ;

;    *** Set gate time ***

         MOV lw    FRES_100        ; Set gate time soon if
        subwf    RESMODE, w        ; resolution >= 100 Hz.
        btfsc    status, c        ;
        goto    set_gtime        ;

         MOV f    EXT_PSC, f        ; Check other mode

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]  下一页


本文关键字:单片机  PIC单片机单片机-工控设备 - PIC单片机