📄 12864.s
字号:
L29:
.dbline 0 ; func end
rjmp pop_xgset303C
.dbsym r s 20 pc
.dbsym r y 12 c
.dbsym r x 10 c
.dbend
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\12864_chuankou_drive.h
_temp::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\12864_chuankou_drive.h
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.dbsym e temp _temp i
_temp_data::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.dbsym e temp_data _temp_data A[2:2]c
_dis_buf_18b20::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.dbsym e dis_buf_18b20 _dis_buf_18b20 A[3:3]c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS18B20_drive.h
.dbfunc e init_1820 _init_1820 fV
.even
_init_1820::
.dbline -1
.dbline 30
; /*********************************************************************
; 返回三个值dis_buf_18b20[0]小数dis_buf_18b20[1]个位dis_buf_18b20[2]十位
; 调用Read_1820_temperature();
; **********************************************************************/
; #include <iom8v.h>
; #include <macros.h>
; #define ddrt DDRD
; #define port PORTD
; #define uchar unsigned char
; #define uint unsigned int
; #define D0 0x01 //18b20端口,PD.0
; #define pin PIND
; #define CL_DQ PORTD&=~(1<<PD0)
; #define SET_DQ PORTD|=(1<<PD0)
; #define SET_OUT DDRD|=(1<<PD0)
; #define SET_IN DDRD&=~(1<<PD0)
; #define IN_DQ PIND&(1<<PD0)
; unsigned int temp=0;
; unsigned char temp_data[2]={0};
; unsigned char dis_buf_18b20[3]={0};
; uchar temp_comp;
; void write_1820(unsigned char x) ;
; /*---------------------------------------------------------------------
; 函数名称:void init_1820()
; 函数功能: 18b20的复位
; 参 数:
; 返 回 值:
; ---------------------------------------------------------------------*/
; void init_1820(void)
; {
.dbline 31
; SET_OUT; //设置端口输出
sbi 0x11,0
.dbline 32
; SET_DQ; //输出一个脉冲
sbi 0x12,0
.dbline 33
; CL_DQ; //低电平保持480us以上
cbi 0x12,0
.dbline 34
; delay_us(500); //延时480us以上
ldi R16,500
ldi R17,1
rcall _delay_us
.dbline 35
; SET_DQ; //没有输出一个脉冲
sbi 0x12,0
.dbline 36
; SET_IN; //设置端口输入,即释放总线,外接上拉电阻,端口被拉高
cbi 0x11,0
.dbline 37
; delay_us(60); //延时15~60us
ldi R16,60
ldi R17,0
rcall _delay_us
L34:
.dbline 38
; while(IN_DQ); //等待应答,即等待低电平信号
L35:
.dbline 38
sbic 0x10,0
rjmp L34
X9:
.dbline 39
; delay_us(80);
ldi R16,80
ldi R17,0
rcall _delay_us
.dbline 40
; SET_OUT; //设置输出
sbi 0x11,0
.dbline 41
; SET_DQ; //输出高电平
sbi 0x12,0
.dbline 42
; delay_us(80); //60~240us
ldi R16,80
ldi R17,0
rcall _delay_us
.dbline -2
L33:
.dbline 0 ; func end
ret
.dbend
.dbfunc e write_1820 _write_1820 fV
; m -> R20
; x -> R10
.even
_write_1820::
st -y,R10
st -y,R20
mov R10,R16
.dbline -1
.dbline 51
; }
; /*---------------------------------------------------------------------
; 函数名称:void write_1820(unsigned char x)
; 函数功能: 写18B20温度
; 参 数: x
; 返 回 值:
; ---------------------------------------------------------------------*/
; void write_1820(unsigned char x) //下降沿写数据
; {
.dbline 54
; unsigned char m;
; //SET_DQ;
; for(m=0;m<8;m++)
clr R20
rjmp L41
L38:
.dbline 55
; {
.dbline 56
; CL_DQ; //写数据,从低位开始
cbi 0x12,0
.dbline 57
; if(x&(1<<m)) //判断数据极性
ldi R16,1
mov R17,R20
rcall lsl8
mov R2,R10
and R2,R16
breq L42
X10:
.dbline 58
; SET_DQ;
sbi 0x12,0
rjmp L43
L42:
.dbline 60
; else
; CL_DQ;
cbi 0x12,0
L43:
.dbline 61
; delay_us(40); //延时15~60us
ldi R16,40
ldi R17,0
rcall _delay_us
.dbline 62
; SET_DQ;
sbi 0x12,0
.dbline 63
; delay_us(1); //连续写两位数据的间隔要大于1us
ldi R16,1
ldi R17,0
rcall _delay_us
.dbline 64
; }
L39:
.dbline 54
inc R20
L41:
.dbline 54
cpi R20,8
brlo L38
X11:
.dbline 65
; SET_DQ; //结束写数据,置高总线
sbi 0x12,0
.dbline -2
L37:
.dbline 0 ; func end
ld R20,y+
ld R10,y+
ret
.dbsym r m 20 c
.dbsym r x 10 c
.dbend
.dbfunc e read_1820 _read_1820 fc
; temp -> R10
; k -> R22
; n -> R20
.even
_read_1820::
rcall push_xgsetF00C
.dbline -1
.dbline 74
; }
; /*---------------------------------------------------------------------
; 函数名称:unsigned char read_1820(void)
; 函数功能: 读取18B20温度
; 参 数:
; 返 回 值: count
; ---------------------------------------------------------------------*/
; unsigned char read_1820(void) //上升沿读数据
; {
.dbline 75
; unsigned char temp=0,k,n;
clr R10
.dbline 76
; for(n=0;n<8;n++)
clr R20
rjmp L48
L45:
.dbline 77
; {
.dbline 78
; CL_DQ; //输出一个起始脉冲
cbi 0x12,0
.dbline 79
; delay_us(1); //保持1us
ldi R16,1
ldi R17,0
rcall _delay_us
.dbline 80
; SET_DQ;
sbi 0x12,0
.dbline 81
; SET_IN; //设端口为输入
cbi 0x11,0
.dbline 82
; k=IN_DQ; //读数据,从低位开始
in R22,0x10
andi R22,1
.dbline 83
; delay_us(1);
ldi R16,1
ldi R17,0
rcall _delay_us
.dbline 84
; if(k) //判断数据极性
tst R22
breq L49
X12:
.dbline 85
; temp|=(1<<n);
ldi R16,1
mov R17,R20
rcall lsl8
or R10,R16
rjmp L50
L49:
.dbline 87
; else
; temp&=~(1<<n);
ldi R16,1
mov R17,R20
rcall lsl8
mov R2,R16
com R2
and R10,R2
L50:
.dbline 88
; delay_us(60); //延时60~120us
ldi R16,60
ldi R17,0
rcall _delay_us
.dbline 89
; SET_OUT; //设端口为输出
sbi 0x11,0
.dbline 90
; }
L46:
.dbline 76
inc R20
L48:
.dbline 76
cpi R20,8
brlo L45
X13:
.dbline 91
; return (temp); //返回读出的数据
mov R16,R10
.dbline -2
L44:
.dbline 0 ; func end
rjmp pop_xgsetF00C
.dbsym r temp 10 c
.dbsym r k 22 c
.dbsym r n 20 c
.dbend
.dbfunc e Read_1820_temperature _Read_1820_temperature fV
; teml -> R12
; temh -> R14
; count -> R10,R11
.even
_Read_1820_temperature::
rcall push_xgset00FC
.dbline -1
.dbline 100
; }
; /*---------------------------------------------------------------------
; 函数名称:unsigned int Read_1820_temperature(void)
; 函数功能: 读取18B20温度,计算
; 参 数:
; 返 回 值: count
; ---------------------------------------------------------------------*/
; void Read_1820_temperature(void)
; {
.dbline 103
; unsigned int count;
; unsigned char temh,teml;
; init_1820(); //复位18b20
rcall _init_1820
.dbline 104
; write_1820(0xcc); //跳过ROM
ldi R16,204
rcall _write_1820
.dbline 105
; write_1820(0x44); //发出温度转换命令
ldi R16,68
rcall _write_1820
.dbline 106
; delay_ms(750);
ldi R16,750
ldi R17,2
rcall _delay_ms
.dbline 107
; init_1820();
rcall _init_1820
.dbline 108
; write_1820(0xcc); //发出读命令
ldi R16,204
rcall _write_1820
.dbline 109
; write_1820(0xbe);
ldi R16,190
rcall _write_1820
.dbline 110
; teml=read_1820(); //读数据
rcall _read_1820
mov R12,R16
.dbline 111
; temh=read_1820();
rcall _read_1820
mov R14,R16
.dbline 112
; temp_data[0]=read_1820();
rcall _read_1820
mov R10,R16
sts _temp_data,R10
.dbline 113
; temp_data[1]=read_1820();
rcall _read_1820
mov R10,R16
sts _temp_data+1,R10
.dbline 114
; count=temh<<8+teml;
mov R18,R12
clr R19
subi R18,248 ; offset = 8
sbci R19,255
mov R16,R14
clr R17
rcall lsl16
movw R10,R16
.dbline 115
; count=count*0.0625;
ldi R16,<L53
ldi R17,>L53
rcall lpm32
movw R2,R16
movw R4,R18
movw R16,R10
rcall uint2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
rcall fpmule2
rcall fpint
.dbline 116
; count=(temh*256+teml)*6.25; //计算具体温度
ldi R16,<L54
ldi R17,>L54
rcall lpm32
movw R2,R16
movw R4,R18
mov R18,R14
clr R19
ldi R16,256
ldi R17,1
rcall empy16s
movw R6,R16
mov R8,R12
clr R9
add R6,R8
adc R7,R9
movw R16,R6
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R2
movw R18,R4
rcall fpmule2
rcall fpint
movw R10,R16
.dbline 117
; dis_buf_18b20[2]=(count%10000)/1000+0x30;
ldi R18,10000
ldi R19,39
rcall mod16u
ldi R18,1000
ldi R19,3
rcall div16u
movw R24,R16
adiw R24,48
sts _dis_buf_18b20+2,R24
.dbline 118
; dis_buf_18b20[1]=(count%1000)/100+0x30;
ldi R18,1000
ldi R19,3
movw R16,R10
rcall mod16u
ldi R18,100
ldi R19,0
rcall div16u
movw R24,R16
adiw R24,48
sts _dis_buf_18b20+1,R24
.dbline 119
; dis_buf_18b20[0]=(count%100)/10+0x30;
ldi R18,100
ldi R19,0
movw R16,R10
rcall mod16u
ldi R18,10
ldi R19,0
rcall div16u
movw R24,R16
adiw R24,48
sts _dis_buf_18b20,R24
.dbline -2
L51:
.dbline 0 ; func end
rjmp pop_xgset00FC
.dbsym r teml 12 c
.dbsym r temh 14 c
.dbsym r count 10 i
.dbend
.dbfile C:\DOCUME~1\Administrator\桌面\16实验\串口显示0\DS1302_drive.h
.dbfunc e read_byte _read_byte fc
; i -> R22
; dat -> R20
.even
_read_byte::
st -y,R20
st -y,R22
.dbline -1
.dbline 27
; #include<iom8v.h>
; #include<macros.h>
; /***复位脚*****/
; #define RST_CLR PORTB&=~(1<<PB2) //电平置地
; #define RST_SET PORTB|=(1<<PB2) //电平置高
; #define RST_IN DDRB&=~(1<<PB2) //方向输入
; #define RST_OUT DDRB|=(1<<PB2) //方向输出
; /*****双向数据******/
; #define IO_CLR PORTB&=~(1<<PB1) //电平置低
; #define IO_SET PORTB|=(1<<PB1) //电平置高
; #define IO_R PINB&(1<<PB1) //电平读取
; #define IO_IN DDRB&=~(1<<PB1) //方向输入
; #define IO_OUT DDRB|=(1<<PB1) //方向输出
; /*********时钟信号********/
; #define SCK_CLR PORTB&=~(1<<PB0) // 时钟信号
; #define SCK_SET PORTB|=(1<<PB0) // 电平置高
; #define SCK_IN DDRB&=~(1<<PB0) //方向输入
; #define SCK_OUT DDRB|=(1<<PB0) //方向输出
; /******************函数声明********************/
; uchar read_byte(void); //读一个字节数据
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -