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

📄 main.s

📁 DS18B20的使用情况以及电路接法和原代码!可以参考做测温电路
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module main.c
	.area text(rom, con, rel)
	.dbfile D:\avr\+++精华+++\+M16范例+\18b20/delay.h
	.dbfunc e delay_1us _delay_1us fV
	.even
_delay_1us::
	.dbline -1
	.dbline 15
; /***************************************
; *              温度计                  *
; * 程序功能: 用18b20探测温度            *
; * 时钟频率: 内部1M                     *
; * 设    计:莫锦攀                     *
; * 修改日期:2007年07月29日             *
; * 编译环境:ICC-AVR6.31                *
; * 实验环境:M16学习板                  *
; * 使用端口: LCD:PC4,PC5,PA4~PA7        *
; *           18b20:PD7                  *
; * 相关说明: 18b20延时要求精确所以单独  *
; *           延时函数.                  *
; *                                      *
; ***************************************/
; 
	.dbline 16
; #include <iom16v.h>						/*包含相关头文件*/
	nop
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e delay_nus _delay_nus fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_delay_nus::
	xcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 20
; #include "1602.h"
; #include "delay.h"
; #include "DS1820.h"
; 
	.dbline 21
; 
	clr R20
	clr R21
	.dbline 22
; void main(void) {
	xjmp L6
L3:
	.dbline 23
	xcall _delay_1us
L4:
	.dbline 22
	subi R20,255  ; offset = 1
	sbci R21,255
L6:
	.dbline 22
	cp R20,R22
	cpc R21,R23
	brlo L3
	.dbline -2
L2:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.dbfunc e delay_1ms _delay_1ms fV
;              i -> R16,R17
	.even
_delay_1ms::
	.dbline -1
	.dbline 27
; 
; 	
; 
; 	DDRA = 0x00;						/*方向输入*/
; 	PORTA = 0xFF;						/*打开上拉*/
	.dbline 29
	clr R16
	clr R17
	xjmp L11
L8:
	.dbline 29
L9:
	.dbline 29
	subi R16,255  ; offset = 1
	sbci R17,255
L11:
	.dbline 29
; 	DDRB = 0xFF;						/*方向输出*/
; 	PORTB = 0xF0;						/*电平设置*/
	cpi R16,116
	ldi R30,4
	cpc R17,R30
	brlo L8
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e delay_nms _delay_nms fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_delay_nms::
	xcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 33
; 	DDRC = 0x00;
; 	PORTC = 0xFF;
; 	DDRD = 0x00;
; 	PORTD = 0xFF;
	.dbline 34
; 
	clr R20
	clr R21
	.dbline 35
; 	delay_nms(100);
	xjmp L16
L13:
	.dbline 36
	xcall _delay_1ms
L14:
	.dbline 35
	subi R20,255  ; offset = 1
	sbci R21,255
L16:
	.dbline 35
	cp R20,R22
	cpc R21,R23
	brlo L13
	.dbline -2
L12:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.dbfile D:\avr\+++精华+++\+M16范例+\18b20/1602.h
	.dbfunc e LCD_init _LCD_init fV
	.even
_LCD_init::
	.dbline -1
	.dbline 44
; 	//ds1820_reset();						/*复位D18B20*/
; 	LCD_init();						/*启动显示任务*/
; 	LCD_write_string(2,0,"Temperature");
; 	while (1) {
; 		ds1820();
; 		LCD_write_string(4,1,temp_1820);
; 		
; 		}
; }
	.dbline 45
; }
	in R24,0x1a
	ori R24,240
	out 0x1a,R24
	.dbline 46
; }
	sbi 0x14,7
	.dbline 47
; }
	sbi 0x14,6
	.dbline 48
; }
	ldi R16,40
	xcall _LCD_write_command
	.dbline 49
; }
	xcall _LCD_en_write
	.dbline 50
; }
	ldi R16,40
	ldi R17,0
	xcall _delay_nus
	.dbline 51
; }
	ldi R16,40
	xcall _LCD_write_command
	.dbline 52
; }
	ldi R16,12
	xcall _LCD_write_command
	.dbline 53
; }
	ldi R16,1
	xcall _LCD_write_command
	.dbline 54
; }
	ldi R16,2
	ldi R17,0
	xcall _delay_nms
	.dbline -2
L17:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_en_write _LCD_en_write fV
	.even
_LCD_en_write::
	.dbline -1
	.dbline 61
; }
; }
; }
; }
; }
; }
; }
	.dbline 62
; }
	sbi 0x15,7
	.dbline 63
; }
	ldi R16,1
	ldi R17,0
	xcall _delay_nus
	.dbline 64
; }
	cbi 0x15,7
	.dbline -2
L18:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_write_command _LCD_write_command fV
;        command -> R20
	.even
_LCD_write_command::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 68
; }
; }
; }
; }
	.dbline 70
; }
; }
	ldi R16,16
	ldi R17,0
	xcall _delay_nus
	.dbline 71
; }
	cbi 0x15,6
	.dbline 72
; }
	in R24,0x1b
	andi R24,15
	out 0x1b,R24
	.dbline 73
; }
	mov R24,R20
	andi R24,240
	in R2,0x1b
	or R2,R24
	out 0x1b,R2
	.dbline 74
; }
	xcall _LCD_en_write
	.dbline 75
; }
	mov R24,R20
	andi R24,#0x0F
	swap R24
	mov R20,R24
	.dbline 76
; }
	in R24,0x1b
	andi R24,15
	out 0x1b,R24
	.dbline 77
; }
	mov R24,R20
	andi R24,240
	in R2,0x1b
	or R2,R24
	out 0x1b,R2
	.dbline 78
; }
	xcall _LCD_en_write
	.dbline -2
L19:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r command 20 c
	.dbend
	.dbfunc e LCD_write_data _LCD_write_data fV
;           data -> R20
	.even
_LCD_write_data::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 95
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 97
; }
; }
	ldi R16,16
	ldi R17,0
	xcall _delay_nus
	.dbline 98
; }
	sbi 0x15,6
	.dbline 99
; }
	in R24,0x1b
	andi R24,15
	out 0x1b,R24
	.dbline 100
; }
	mov R24,R20
	andi R24,240
	in R2,0x1b
	or R2,R24
	out 0x1b,R2
	.dbline 101
; }
	xcall _LCD_en_write
	.dbline 102
; }
	mov R24,R20
	andi R24,#0x0F
	swap R24
	mov R20,R24
	.dbline 103
; }
	in R24,0x1b
	andi R24,15
	out 0x1b,R24
	.dbline 104
; }
	mov R24,R20
	andi R24,240
	in R2,0x1b
	or R2,R24
	out 0x1b,R2
	.dbline 105
; }
	xcall _LCD_en_write
	.dbline -2
L20:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e LCD_set_xy _LCD_set_xy fV
;        address -> R20
;              y -> R20
;              x -> R22
	.even
_LCD_set_xy::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 124
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 126
; }
; }
	tst R20
	brne L22
	.dbline 126
	mov R20,R22
	subi R20,128    ; addi 128
	xjmp L23
L22:
	.dbline 127
; }
	mov R20,R22
	subi R20,64    ; addi 192
L23:
	.dbline 128
; }
	mov R16,R20
	xcall _LCD_write_command
	.dbline -2
L21:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r address 20 c
	.dbsym r y 20 c
	.dbsym r x 22 c
	.dbend
	.dbfunc e LCD_write_string _LCD_write_string fV
;              s -> R20,R21
;              Y -> R10
;              X -> R22
	.even
_LCD_write_string::
	xcall push_gset3
	mov R10,R18
	mov R22,R16
	ldd R20,y+6
	ldd R21,y+7
	.dbline -1
	.dbline 132
; }
; }
; }
; }
	.dbline 133
; }
	mov R18,R10
	mov R16,R22
	xcall _LCD_set_xy
	xjmp L26
L25:
	.dbline 135
	.dbline 136
	movw R30,R20
	ldd R16,z+0
	xcall _LCD_write_data
	.dbline 137
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 138
L26:
	.dbline 134
; }
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L25
	.dbline -2
L24:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r s 20 pc
	.dbsym r Y 10 c
	.dbsym r X 22 c
	.dbend
	.dbfunc e LCD_write_char _LCD_write_char fV
;           data -> y+4
;              Y -> R22
;              X -> R20
	.even
_LCD_write_char::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	.dbline -1
	.dbline 143
; }
; }
; }
; }
; }
; }
; }
; }
; }
	.dbline 144
; }
	mov R18,R22
	mov R16,R20
	xcall _LCD_set_xy
	.dbline 145
; }
	ldd R16,y+4
	xcall _LCD_write_data
	.dbline -2
L28:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l data 4 c
	.dbsym r Y 22 c
	.dbsym r X 20 c
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\avr\+++精华+++\+M16范例+\18b20/1602.h
_temp_1820::
	.blkb 2
	.area idata
	.byte 0,0
	.area data(ram, con, rel)
	.dbfile D:\avr\+++精华+++\+M16范例+\18b20/1602.h
	.blkb 2
	.area idata
	.byte 0,46
	.area data(ram, con, rel)

⌨️ 快捷键说明

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