;################################################
; Designed by CaoHai 10-23-2002 in SDUWHB ;
; Updated by CaoHai 12-12-2002 in SDUWHB ;
; Upgraded by CaoHai 22-12-2002 in SDUWHB ;
; Upgraded by CaoHai 05-05-2003 in SDUWHB ;
;################################################
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;标号定义
data_len equ 0ch ;温度数据长度
data_buf equ 50h ;温度数据缓冲区
;虚拟引脚定义(For SPI BUS)
vcs equ p1.0 ;片选线
vio equ p1.1 ;数据线
vsc equ p1.2 ;时钟线
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;================================================
;模块GetData ;参数:无参数
;功能:用spi总线从LM74温度传感器读取温度数据
;返回:无
GetData:
clr ea
clr vcs
setb vio
mov r1,#08h
clr vsc ;读符号位
nop
nop
nop
setb vsc
nop
nop
nop
mov f0,vio
read_bite: ;读数据
clr vsc
nop
nop
nop
setb vsc
nop
nop
nop
mov c,vio
rlc a
djnz r1,read_bite
setb vcs
;转换数据
mov data_buf+1,#2bh ;'+'
jnb f0,fill_data
dec a
cpl a
mov data_buf+1,#2bh ;'-'
fill_data:
mov data_buf+2,#30h
mov data_buf+3,#30h
mov data_buf+4,#30h
mov data_buf+5,#0a1h ;℃-l
mov data_buf+6,#0e6h ;℃-h
mov data_buf+7,#3bh ;;
mov data_buf+8,#20h ;
mov data_buf+9,#30h ;
mov data_buf+10,#30h ;
mov data_buf+11,#31h ;
mov data_buf+12,#7ch ;|
mov r0,#data_buf+4
pide_data:
mov b,#0ah
p ab
mov r1,a
mov a,b
add a,#30h
mov @r0,a
dec r0
mov a,r1
jnz pide_data
mov data_buf,#data_len
setb ea
ret