DS18b20 and PIC microcontroller communication source program

Publisher:cheng1984Latest update time:2014-01-09 Source: pic16Keywords:DS18b20 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
     ORG     PIC54
     GOTO    MAIN
     ORG     0
;----------------------
;----------------------------
DELAY22            
        MOVLW   D'200'               ; DELAY 2*250=500mS
        MOVWF    COUNT1
DE32    MOVLW   D'250'                ; 8*250=2mS
    MOVWF    COUNT2
DE42    NOP                          ; 1+2+1=5uS
        DECFSZ    COUNT2,1
        GOTO    DE42
        DECFSZ    COUNT1,1
        GOTO    DE32
        RETLW   0             
;--------------------------------
;       子程序!!!
;********************************
MAIN
        MOVLW  0FFH
        TRIS   RA
LOOP
        CALL   CONVERT
        CALL   DELAY22
        CALL   DELAY22
        CALL   GET_TEMP

        GOTO   LOOP
;------------------------
GET_TEMP
       CALL   INI
       MOVLW  0CCH
       MOVWF  COMD
       CALL   WR1820
       MOVLW  0BEH
       MOVWF  COMD
       CALL   WR1820
       CALL   RE1820
       MOVF   TEM_DATE,W
       MOVWF  TEM_DATEL
       CALL   RE1820
       MOVF   TEM_DATE,W
       MOVWF  TEM_DATEH
       RETLW  0
;------------------------
CONVERT
        CALL   INI
        MOVLW  0CCH
        MOVWF  COMD
        CALL   WR1820
        MOVLW  44H
        MOVWF  COMD
        CALL   WR1820
        RETLW  0

;---------DS1820---------
INI
     ;MOVLW  B'00100000'
     MOVLW  0
     TRIS   RA
     BSF    RA,3
     NOP
     BCF    RA,3
     MOVLW  D'200'
     MOVWF  COUNT1
L0
     DECFSZ COUNT1,1
     GOTO   L0
     ;MOVLW  B'01100000'
     MOVLW  0FH
     TRIS   RA
     MOVLW  D'30'
     MOVWF  COUNT1
L1
     DECFSZ COUNT1,1
     GOTO   L1
     BTFSC  RA,3
     GOTO   INI
L2
     MOVLW  D'80'
     MOVWF  COUNT1
L3
     DECFSZ COUNT1,1
     GOTO   L3
     BTFSS  RA,3
     GOTO   L0
     RETLW  0
;-------------------------
WR1820
     MOVLW   8
     MOVWF   COUNT2
WR0
     ;MOVLW   B'00100000'
     MOVLW   0
     TRIS    RA
     BCF     RA,3
     NOP
     NOP
     MOVLW   2
     MOVWF   COUNT1
WR1     
     DECFSZ  COUNT1,1
     GOTO    WR1
     ;MOVLW   B'01111111'
     MOVLW   0FH
     BTFSC   COMD,0
     BSF     RA,3
     BTFSC   COMD,0
     TRIS    RA
     BCF     STATUS,C
     RRF     COMD,1
     MOVLW   D'20'
     MOVWF   COUNT1
WR2
     DECFSZ  COUNT1,1
     GOTO    WR2
     BSF     RA,3
     ;MOVLW   B'01100000'
     MOVLW   0FH
     TRIS    RA
     DECFSZ  COUNT2,1
     GOTO    WR0
     RETLW   0
;--------------------------
RE1820
     MOVLW   8
     MOVWF   COUNT2
RE0
     ;MOVLW   B'00100000'
     MOVLW   0
     TRIS    RA
     BCF     RA,3      
     MOVLW   2
     MOVWF   COUNT1
RE1     
     DECFSZ  COUNT1,1
     GOTO    RE1
     ;MOVLW   B'01100000'
     MOVLW   0FH
     TRIS    RA
     NOP
     BTFSS   RA,3
     BCF     STATUS,C
     BTFSC   RA,3
     BSF     STATUS,C    
     RRF     TEM_DATE,1
     MOVLW   D'20'
     MOVWF   COUNT1
RE2
     DECFSZ  COUNT1,1
     GOTO    RE2
     DECFSZ  COUNT2,1
     GOTO    RE0
     BSF     RA,3
     RETLW   0
;-------------------------      
;****************************
;**************************
         END
Keywords:DS18b20 Reference address:DS18b20 and PIC microcontroller communication source program

Previous article:Using PIC16C54 Single Chip Microcomputer to Make a Simple AM ​​Frequency Counter
Next article:Timer based on PIC12C508 microcontroller

Recommended ReadingLatest update time:2024-11-16 16:25

Application of DS18B20 in bridge concrete temperature measurement
Abstract: This article briefly introduces the new features of the single-wire digital temperature sensor DS18B20 of the American DALLAS company based on its predecessor product DS1820, as well as the more detailed interface circuit and read and write timing with the microcontroller, and its applica
[Test Measurement]
DS18B20 source program based on WinAVR
#ifndef _DS18B20_C_ #define _DS18B20_C_ #define DQ_18B20 (1 3) // PD3 #define DQ_TO_0() (DDRD |= DQ_18B20) // PD3=’0′ #define DQ_TO_1() (DDRD &= ~DQ_18B20) // PD3=’float’ #define DQ_status() (PIND & DQ_18B20) // read PD3 pin #ifndef CPU_CRYSTAL #define CPU_CRYSTAL (11.0592) #endif #define wait_us(us) _d
[Microcontroller]
Design of networked intelligent temperature sensor based on ARM and DS18B20
1 Introduction to Networked Intelligent Sensors Networked intelligent sensors enable sensors to develop from single function and single detection to multi-function and multi-point detection; from passive detection to active information processing; from on-site measurement to long-distance real-time online measurement
[Microcontroller]
Design of networked intelligent temperature sensor based on ARM and DS18B20
STM8L controls the temperature sensor DS18B20
#define DS18B20_GPIO_PORT (GPIOC) #define DS18B20_GPIO_PIN (GPIO_Pin_2) #define DS18B20_PIN_SET_OUT() GPIO_Init(DS18B20_GPIO_PORT, (GPIO_Pin_TypeDef)DS18B20_GPIO_PIN, GPIO_Mode_Out_PP_High_Fast) #define DS18B20_PIN_SET_IN() GPIO_Init(DS18B20_GPIO_PORT, (GPIO_Pin_TypeDef)DS18B20_GPIO_PIN, GPIO_Mode_In_PU_No_IT) #def
[Microcontroller]
Application of digital temperature sensor DS18B20 in satellite power supply system
  0 Preface    The satellite power supply system is mainly used to provide a stable power supply for the normal operation of the entire satellite. It is an important subsystem for satellite power generation, storage, conversion, regulation, transmission, distribution and management. Its basic function is to conver
[Microcontroller]
Application of digital temperature sensor DS18B20 in satellite power supply system
51 MCU ~ DS18B20 temperature sensor
1. Introduction: (ii) Wiring: 1. Internal structure: The first five digits of positive temperature are 0. The first five digits of negative temperature are 1. A four-digit hexadecimal number consisting of LS and MS, and a 16-digit binary number. (MS first, then LS) Combine the above and below graphs to get
[Microcontroller]
51 MCU ~ DS18B20 temperature sensor
C language program using DS18B20 temperature sensor in single chip microcomputer (reference 7)
Hardware: 51 board      (1) Single-wire ds18b20 connected to P2.2      (2) Use external power to power ds18b20, no parasitic power Software:       Kei uVision 2 #include "reg52.h" #include "intrins.h" #define uchar unsigned char #define uint unsigned int sbit ds=P2^2; sbit dula=P2^6; sbit wela=P2^7; uchar
[Microcontroller]
DS18B20+PIC temperature measurement using 1602 to display temperature C program
//Be familiar with using the MCU to test the temperature using the DS18B20 temperature sensor and display the temperature using the 1602 display //1. The first line displays: Temperature //2. The second line displays: the measured temperature value //************************************************** //***********
[Microcontroller]
502 Bad Gateway

502 Bad Gateway


openresty
502 Bad Gateway

502 Bad Gateway


openresty
502 Bad Gateway

502 Bad Gateway


openresty
502 Bad Gateway

502 Bad Gateway


openresty
Guess you like
    502 Bad Gateway

    502 Bad Gateway


    openresty

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
502 Bad Gateway

502 Bad Gateway


openresty