⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dal_bus.lst

📁 转载别人ds18b20proteus作品希望对proteus library里没有ds18b20的xdjm们有用!
💻 LST
📖 第 1 页 / 共 5 页
字号:
MPASM 03.80 Released                              DAL_BUS.ASM   11-20-2005  18:21:08         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;        TITLE "Dallas 1 wire bus comms MASTER"
                      00002 
                      00003 ;****************************************************************************
                      00004 ;*
                      00005 ;*   Send Reset Pulse to all on Dallas bus,
                      00006 ;*   and monitor presence pulse
                      00007 ;* TO DO -  best of three reads, to guard against noise
                      00008 ;*
                      00009 ;****************************************************************************
                      00010 
                      00011     include P16F628A.inc
                      00001         LIST
                      00002 ; P16F628A.INC  Standard Header File, Version 1.10    Microchip Technology, Inc.
                      00265         LIST
                      00012     include tempdemo.inc
                      00001 ;****************************************************************************
                      00002 ;*                                                                          *
                      00003 ;*                   Dallas 1 Wire Bus Temperature demo                     *
                      00004 ;*                                                                          *
                      00005 ;****************************************************************************
                      00006 
  003D0900            00007 Clock_Freq      equ     d'4000000'      ;4MHz - for wait macro calculations
                      00008 
                      00009     udata_ovr   0x20                    ;0x0C 16F84
0020                  00010 DScommbuff      res     1
0021                  00011 DSCRC           res     1
                      00012 
0022                  00013 tempone         res     1
0023                  00014 temptwo         res     1
0024                  00015 count           res     1
0025                  00016 count2          res     1               ; 2nd loop counter for nested loops
0026                  00017 bits_byte       res     1
                      00018 
0027                  00019 CHARBUF         res     1
0028                  00020 temp_hi         res     1
0029                  00021 temp_lo         res     1
002A                  00022 acc_lo          res     1
002B                  00023 acc_hi          res     1
                      00024 
002C                  00025 vvshift         res     1
                      00026 
                      00027 #define PRESENCE_bit    bits_byte, 0
                      00028 #define round00_bit     bits_byte, 1
                      00029 #define DSNext_bit      bits_byte, 2
                      00030 #define neg_temp_bit    bits_byte, 3
                      00031 #define DALLAS_BUS      PORTA, 4
                      00032 
002D                  00033 ROM_no          res     8
0035                  00034 id_bit_number   res     1
0036                  00035 last_zero       res     1
0037                  00036 LastDiscrepancy res     1
0038                  00037 LastFamilyDiscr res     1
0039                  00038 id_bits_byte    res     1
MPASM 03.80 Released                              DAL_BUS.ASM   11-20-2005  18:21:08         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

003A                  00039 rom_mask        res     1
                      00040 
                      00041 #define id_bit          id_bits_byte, 0 ; first bit read in a search ID sequence
                      00042 #define cmp_id_bit      id_bits_byte, 1 ; complement of id_bit
                      00043 #define test_bit        id_bits_byte, 2 ; test id_bit & cmp_id_bit
                      00044 
                      00045 #define last_device     id_bits_byte, 6
                      00046 #define Direction       id_bits_byte, 7
                      00013     include dal_bus.inc
                      00032         list
                      00014     include wait.inc
                      00001 
                      00002 #define         Nanosec         * D'1'
                      00003 #define         Microsec        * D'1000'
                      00004 #define         Millisec        * D'1000000'
                      00005 #define         Seconds         * D'1000000000'
                      00006        
                      00007 
                      00008 ;**************************************************************
                      00009 ;*                       The WAIT macro                       *
                      00010 ;*                      * VERSION 1.01 *                      *
                      00011 ;*             called by Wait <time>, lesscycles              *
                      00012 ;**************************************************************
                      00013 ;History
                      00014 ;1.00   - Original
                      00015 ;1.01   - Fixed bug with small even numbers giving an error message
                      00016 
                      00017 
                      00018 Wait    macro   time_ns, lesscycles         ;time_ns gives the wait time required, in ns
                      00019  radix dec
                      00020  variable instruct_time_ns =  (( 1 Seconds ) / (Clock_Freq / 4 ))
                      00021  local cycles
                      00022  variable cycles = ((time_ns) / instruct_time_ns)   ;required delay in 
                      00023                                                          ;100ths of instructions
                      00024 
                      00025  if (cycles < (lesscycles) )
                      00026         messg NOTE - negative delay time with lesscycles cycles (no code)
                      00027                
                      00028                 exitm
                      00029  else
                      00030  variable cycles = (cycles - (lesscycles))
                      00031  endif
                      00032 
                      00033  if (cycles == 0) 
                      00034         messg "WARNING - delay time less than 1 instructions"
                      00035                
                      00036                 nop
                      00037                 exitm
                      00038  endif
                      00039 
                      00040  if (cycles > (255*(256*3 + 6) + 2 + 3))
                      00041         messg   "ERROR : Too long a wait for the WAIT macro at present!!"
                      00042         exitm
MPASM 03.80 Released                              DAL_BUS.ASM   11-20-2005  18:21:08         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00043  endif
                      00044         
                      00045 ;        messg Info - calculated number of cycles = #v(cycles)
                      00046 
                      00047 
                      00048  if (cycles > ((255*3)+5))
                      00049                 
                      00050                 movlw   ((cycles-5)/(256*3+6))
                      00051                 call    longdelay
                      00052  
                      00053  ifndef INCLONGDELAY
                      00054   #define INCLONGDELAY
                      00055  endif
                      00056 
                      00057  exitm
                      00058  endif
                      00059 
                      00060  if ((cycles > 8 ) && (cycles < (255*3 + 5)))
                      00061                 
                      00062                 movlw   ((cycles-5)/3)        
                      00063                 call    shortdelay
                      00064  
                      00065  ifndef INCSHORTDELAY
                      00066   #define INCSHORTDELAY
                      00067  endif
                      00068 
                      00069  exitm
                      00070  endif
                      00071 
                      00072  if (cycles < 8)
                      00073  while  ( cycles > 1 )
                      00074                 
                      00075                 goto $+1  ;two cycle nop
                      00076         
                      00077 cycles -=2
                      00078  endw
                      00079  endif
                      00080  
                      00081  if (cycles > 0)
                      00082                nop
                      00083  
                      00084  endif
                      00085  exitm
                      00086  
                      00087  messg "ERROR - got to end of WAIT.MAC"
                      00088 
                      00089  radix hex
                      00090  endm
                      00015 
  0000                00016     global DSReset_Pulse, DSWriteByteW, DSReadByte, DSReadBit
  0000                00017     global OWSearch
  0000                00018     extern longdelay, shortdelay    ;DELAY.ASM
                      00019 
MPASM 03.80 Released                              DAL_BUS.ASM   11-20-2005  18:21:08         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00020 PROG CODE
0000   1000           00021 DSReset_Pulse   bcf     PRESENCE_bit
0001   1605           00022                 bsf     DALLAS_BUS      ;just in case it isn't
                      00023                 Wait    1 Microsec,0    ; Trec
                          M  radix dec
  03E8                    M  variable instruct_time_ns =  (( 1 Seconds ) / (Clock_Freq / 4 ))
  0000                    M  local cycles
  0001                    M  variable cycles = ((1 * D'1000') / instruct_time_ns) ;required delay in 
                          M                                                          ;100ths of instructions
                          M 
                          M  if (cycles < (0)          )
                          M         messg NOTE - negative delay time with 0          cycles (no code)
                          M                
                          M                 exitm
                          M  else
  0001                    M  variable cycles = (cycles - (0))
                          M  endif
                          M 
                          M  if (cycles == 0) 
                          M         messg "WARNING - delay time less than 1 instructions"
                          M                
                          M                 nop
                          M                 exitm
                          M  endif
                          M 
                          M  if (cycles > (255*(256*3 + 6) + 2 + 3))
                          M         messg   "ERROR : Too long a wait for the WAIT macro at present!!"
                          M         exitm
                          M  endif
                          M         
                          M ;        messg Info - calculated number of cycles = #v(cycles)
                          M 
                          M 
                          M  if (cycles > ((255*3)+5))
                          M                 
                          M                 movlw   ((cycles-5)/(256*3+6))
                          M                 call    longdelay
                          M  
                          M  ifndef INCLONGDELAY
                          M   #define INCLONGDELAY
                          M  endif
                          M 
                          M  exitm
                          M  endif
                          M 
                          M  if ((cycles > 8 ) && (cycles < (255*3 + 5)))
                          M                 
                          M                 movlw   ((cycles-5)/3)        
                          M                 call    shortdelay
                          M  
                          M  ifndef INCSHORTDELAY
                          M   #define INCSHORTDELAY
                          M  endif
MPASM 03.80 Released                              DAL_BUS.ASM   11-20-2005  18:21:08         PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                          M 
                          M  exitm
                          M  endif
                          M 
                          M  if (cycles < 8)
                          M  while  ( cycles > 1 )
                          M                 
                          M                 goto $+1  ;two cycle nop
                          M         
                          M cycles -=2
                          M  endw
                          M  endif
                          M  
                          M  if (cycles > 0)
0002   0000               M                nop

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -