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

📄 ds1620.asm

📁 web51的开发库
💻 ASM
字号:
;#############################################################;# PROCEDURY pro komunikaci s teplotnim cidlem Dallas DS1620 #;#############################################################;.equ	RST_SPI, 0x90	; P1.0.equ	CLK_SPI, 0x91	; P1.1.equ	DQ_SPI,  0x92	; P1.2.global init_ds1620.global read_ds1620	.comm	lasttemp, 1	.text	.using	0read_ds1620:	clr	RST_SPI		; drop reset	setb	CLK_SPI		; raise clock	setb	DQ_SPI		; make DQ1620 an input	setb	RST_SPI		; raise reset	mov	a,#0xEE		; CMD: Start Convert	lcall	spiout		; send it to DS1620	clr	RST_SPI		; drop reset	mov	dptr,#0x0100	; timeoutLcnvprg:inc	dptr	mov	a,dph	jz	Lcnvtimeout	setb	RST_SPI		; raise reset	mov	a,#0xAC		; CMD: Read Config	lcall	spiout		; send it to DS1620	lcall	spiin		; get status from ds1620	clr	RST_SPI		; drop reset	jnb	acc.7,Lcnvprg	; Conversion in progressLcnvgo:	nop	nop	setb	RST_SPI		; raise reset	mov	a,#0xAA		; CMD: Read Temperature	lcall	spiout	lcall	spiin		; get temp data from ds1620 ( LSB )	mov	r3,a		; move (LSB) of temp data to Storage Register.	lcall	spiin		; get temp data from ds1620 ( MSB )	clr	RST_SPI		; drop reset	anl	a,#1	jz	Lpositivetemp	mov	a,r3	add	a,#50	jc	Lminus50	clr	aLminus50:mov	lasttemp,a	mov	a,r3	cpl	a	inc	a	mov	r3,a	mov	a,#'-'	sjmp	LsendtempLpositivetemp:	mov	a,r3	add	a,#50	jnc	Lplus103	mov	a,#255Lplus103:mov	lasttemp,a	mov	a,#'+'Lsendtemp:	push	ar3	lcall	sendchar	pop	acc	push	acc	clr	C	rrc	a	lcall	sendDecb	mov	a,#'.'	lcall	sendchar	pop	acc	rrc	a	mov	a,#'0'	jnc	Ltempe	mov	a,#'5'Ltempe:	lcall	sendchar	retLcnvtimeout:	lcall	send_string	.asciz	"Error"	ret	.section reset_device, #allocinit_ds1620:	clr	RST_SPI		; drop reset	setb	CLK_SPI		; raise clock	setb	DQ_SPI		; make DQ1620 an input	mov	a,#0x0C		; CMD: Write config	setb	RST_SPI		; raise reset	lcall	spiout		; send it to DS1620	MOV	A,#0x03		; set config byte = 3				;  CPU mode, one shot	lcall	spiout		; send it to DS1620;;&&& end of DS1620 &&&;	;; end

⌨️ 快捷键说明

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