📄 ds2435.hpl
字号:
; Orange programmer module v3.4
; (c) 2000,2001 Alex Plusov
; Dallas Battery Identification Chip
; CHIP=DS2435,32(32),ds2435.hpl
;Tested!
; May be speed correction need for other PC!!!
; Connect _____
; 1 GND |DS243|
; 2 DQ (P1) |_____|
; 3 Vcc | | |
; | | |
; 1 2 3
; Provides unique ID number to battery packs
; Eliminates thermistors by sensing battery tempera-ture on-chip
; Elapsed time counter provides indication of battery usage/storage time
; Time/Temperature histogram function provides
; essential information for determining battery self-dis-charge
; 256-bitnonvolatile user memory available for storage
; of user data such as gas gauge and manufacturing
; information.
SOCKET=0
PINO=DQ,1
PINI=DQ,1
CDELAY = 0 ; one set delay
R9=CRC,H
[_RESET]
R8=0 ; status
DQ=1,P=200
IDISABLE
DQ=0,P=650
DQ=1
P=1
; Wait answer
LOOP=(0,10000){
R8[0]=DQ
R8[0]?0{BREAK}
}
R8[0]?1{R8[1]=1} ;check state timeout
LOOP=(0,10000){
R8[0]=DQ
R8[0]?1{BREAK}
}
R8=^1;
IENABLE
P=1000
[_CRCBYTE]
R0=DATA ; DATA
LOOP=(0,7){ ; BITS LOOP
R1=R0
R1=^R9
R1=&1 ; CF
R1?1{R9=^0x18}
;R9[8]=R9[0]
R9=>>1,R9=&0xFF
R1=<<7
R9=|R1
R0=>>1
}
[_CRCALL]
ADR=0
R9=0
LOOP=(0,7){ ; BYTES LOOP
_CRCBYTE
ADR=+1
}
[INIT]
DQ=1,P=500
;_RESET
;R8?!0{PRINT=("ANSWER ERROR %lX",R0),EXIT}
[_TBYTE]
R1=0
LOOP=(0,7){
DQ=0,P=5
DQ=R0[I]
P=3
R1[I]=DQ
P=70
DQ=1
P=20
}
[READBLOCK]
;TX Reset Reset pulse (480-960 ms)
;RX Presence Presence pulse
;TX 71h Issue "copy NV1 to SP1" command
;RX <busy indicator> Wait until NVB in status register=1 (2-5 ms typical)
;TX Reset Reset pulse
;RX Presence Presence pulse
;TX 11h Issue "read scratchpad" command
;TX 00h Start address
;RX <24 data bytes> Read scratchpad data
_RESET
R8?!0{PRINT=("ANSWER ERROR %lX",R8),EXIT}
P=200
IDISABLE
R0=0x71,_TBYTE
IENABLE
P=5000
_RESET
IDISABLE
R0=0x11,_TBYTE
R0=0x00,_TBYTE
LOOP=(0,23){R0=0xFF,_TBYTE,DATA=R1,ADR=+1}
IENABLE
;TX Reset Reset pulse (480-960 ms)
;RX Presence Presence pulse
;TX 77h Issue "copy NV2 to SP2" command
;RX <busy indicator> Wait until NVB in status register=1 (2-5 ms typical)
;TX Reset Reset pulse
;RX Presence Presence pulse
;TX 11h Issue "read scratchpad" command
;TX 20h Start address
;RX <24 data bytes> Read scratchpad data
;TX Reset Reset pulse
;RX Presence Presence pulse, done
_RESET
R8?!0{PRINT=("ANSWER ERROR %lX",R8),EXIT}
P=200
IDISABLE
R0=0x77,_TBYTE
IENABLE
P=5000
_RESET
IDISABLE
R0=0x11,_TBYTE
R0=0x20,_TBYTE
LOOP=(0,7){R0=0xFF,_TBYTE,DATA=R1,ADR=+1}
IENABLE
[_TEMPGET]
;MASTER MODE DATA (LSB FIRST) COMMENTS
_RESET ;TX Reset Reset pulse (480-960 ms)
;RX Presence Presence pulse
R8?!0{PRINT=("ANSWER ERROR %lX",R8),EXIT}
P=200,IDISABLE
R0=0xD2,_TBYTE ;TX D2h Issue "convert T" command
IENABLE
_RESET ;TX Reset Reset pulse
;RX Presence Presence pulse
;IDISABLE
;R0=0xB2,_TBYTE ;TX B2h Issue "read registers" command; begin loop
;R0=0x62,_TBYTE ;TX 62h Status register address
;R0=0xFF,_TBYTE ;RX <1 data byte> Read status register and loop until TB=0
;IENABLE
P=500000 ;Conversion time
_RESET ;TX Reset Reset pulse
;RX Presence Presence pulse
IDISABLE
R0=0xB2,_TBYTE ;TX B2h Issue "read registers" command
R0=0x60,_TBYTE ;TX 60h Temperature register address
R0=0xFF,_TBYTE ;RX <1 data byte> Read temperature register
IENABLE
_RESET ;TX Reset Reset pulse
;RX Presence Presence pulse, done
R2=R1
R1=/2
R2=&1,R2=*5
[TEMPERATURE]
_TEMPGET
PRINT=("TEMPERATURE %lu.%lu 'C",R1,R2)
; "Living" conversion
[TEMPLOOP]
LOOP=(0,32768){
_TEMPGET
PRINT=S("TEMPERATURE %lu.%lu 'C",R1,R2)
P=500000 ;sleep :)
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -