您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机12F675温度显示程序 正文
12F675温度显示程序

12F675温度显示程序

点击数:7946 次   录入时间:03-04 12:00:56   整理:http://www.55dianzi.com   PIC单片机
;title  "DS1620 - 12F675温度LCD显示 
;  Shift Data:
;  Bit 1 - Always High (Gate for "E")
;  Bit 2 - RS Bit
;  Bit 3 - LCD D4
;  Bit 4 - LCD D5
;  Bit 5 - LCD D6
;  Bit 6 - LCD D7
;
;  
;   12F675  4 MHz 
;   GPIO.0 is the LCD Data Bit
;   GPIO.1 is the LCD CLOCk Bit
;   GPIO.2 is the DS1620 Data Bit
;   GPIO.3 is MCLR
;   GPIO.4 is the DS1620 Clock Bit
;   GPIO.5 is the DS1620 Reset Bit
;
;
  LIST P=12F675, R=DEC        
  INCLUDE "p12f675.inc"

#DEFINE    Data    GPIO,0
#DEFINE    Clock    GPIO,1
#DEFINE DSDQ    GPIO,2
; MCLR uses     GPIO,3
#DEFINE DSCLK   GPIO,4
#DEFINE DSRST   GPIO,5

    org    0

    bsf    STATUS,RP0
    MOVlw    0x00        
    MOVwf    TRISIO
    MOVlw    b’11011100’    
    MOVwf    OPTION_REG
    clrf    ANSEL        
    bcf    STATUS,RP0

    clrf    STATUS
    clrf    INTCON        
    clrf    GPIO

    MOVlw    0x07
    MOVwf    CMCON        
    call    InitLCD
    call    SndMsg        
    call    InitDS

MAIN    MOVlw    0xc0        ;  line 2 on LCD
    call    SendINS

    call    GetTemp        ; 读温度
    call    SendDEC        ; LCD显示

    goto    MAIN
;---------------------------------------------------------------
;  DS1620 子程序
StartC    MACRO
    bsf    DSRST
    ENDM

StopC    MACRO
    bcf    DSRST
    ENDM

InitDS    StartC
    MOVlw    0x0c        
    call    SndByte
    MOVlw    b’00001010’    
    call    SndByte
    StopC

    nop

    StartC
    MOVlw    0xEE        
    call    SndByte
    StopC
    return

GetTemp    MOVlw    0xAA        
    StartC
    call    SndByte        
    nop
    call    RdByte        
    StopC
    return

SndByte    MOVwf    NOTemp        
    MOVlw    8        
    MOVwf    NOTmp1
DSLoop1
    bcf    DSCLK
    rrf    NOTemp,f    
    btfss    STATUS,C    
    goto    DSCLR        
    bsf    DSDQ        
    goto    DSLp1
DSCLR    bcf    DSDQ
    nop
DSLp1    bsf    DSCLK
    decfsz    NOTmp1,f    
    goto    DSLoop1
    return

RdByte    clrf    NOTemp        
    MOVlw    8        
    MOVwf    NOTmp1
    bsf    STATUS,RP0    
    bsf    TRISIO,2
    bcf    STATUS,RP0
DSLoop2
    bcf    DSCLK        
    nop
    rrf    NOTemp,f    
    btfss    DSDQ        
    goto    DSCLR2        
    bsf    NOTemp,7    
    goto    DSLp2
DSCLR2    bcf    NOTemp,7
    nop
DSLp2    bsf    DSCLK
    decfsz    NOTmp1,f    
    goto    DSLoop2
    bsf    STATUS,RP0    
    bcf    TRISIO,2
    bcf    STATUS,RP0
    MOVfw    NOTemp        

[1] [2] [3] [4]  下一页


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