📄 ds1302_mega16.s
字号:
xcall _LCD_write_string
.dbline 31
xjmp L35
L39:
.dbline 32
; case 1 : LCD_write_string(12,2,".06");break;
ldi R24,<L40
ldi R25,>L40
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 32
xjmp L35
L41:
.dbline 33
; case 2 : LCD_write_string(12,2,".12");break;
ldi R24,<L42
ldi R25,>L42
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 33
xjmp L35
L43:
.dbline 34
; case 3 : LCD_write_string(12,2,".18");break;
ldi R24,<L44
ldi R25,>L44
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 34
xjmp L35
L45:
.dbline 35
; case 4 : LCD_write_string(12,2,".25");break;
ldi R24,<L46
ldi R25,>L46
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 35
xjmp L35
L47:
.dbline 36
; case 5 : LCD_write_string(12,2,".31");break;
ldi R24,<L48
ldi R25,>L48
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 36
xjmp L35
L49:
.dbline 37
; case 6 : LCD_write_string(12,2,".37");break;
ldi R24,<L50
ldi R25,>L50
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 37
xjmp L35
L51:
.dbline 38
; case 7 : LCD_write_string(12,2,".43");break;
ldi R24,<L52
ldi R25,>L52
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 38
xjmp L35
L53:
.dbline 39
; case 8 : LCD_write_string(12,2,".50");break;
ldi R24,<L54
ldi R25,>L54
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 39
xjmp L35
L55:
.dbline 40
; case 9 : LCD_write_string(12,2,".56");break;
ldi R24,<L56
ldi R25,>L56
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 40
xjmp L35
L57:
.dbline 41
; case 10 : LCD_write_string(12,2,".61");break;
ldi R24,<L58
ldi R25,>L58
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 41
xjmp L35
L59:
.dbline 42
; case 11 : LCD_write_string(12,2,".68");break;
ldi R24,<L60
ldi R25,>L60
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 42
xjmp L35
L61:
.dbline 43
; case 12 : LCD_write_string(12,2,".75");break;
ldi R24,<L62
ldi R25,>L62
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 43
xjmp L35
L63:
.dbline 44
; case 13 : LCD_write_string(12,2,".81");break;
ldi R24,<L64
ldi R25,>L64
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 44
xjmp L35
L65:
.dbline 45
; case 14 : LCD_write_string(12,2,".87");break;
ldi R24,<L66
ldi R25,>L66
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 45
xjmp L35
L67:
.dbline 46
; case 15 : LCD_write_string(12,2,".93");break;
ldi R24,<L68
ldi R25,>L68
std y+1,R25
std y+0,R24
ldi R18,2
ldi R16,12
xcall _LCD_write_string
.dbline 46
L34:
L35:
.dbline -2
L33:
.dbline 0 ; func end
adiw R28,2
xjmp pop_xgsetF03C
.dbsym r temp_decimal 20 c
.dbsym r temp_num 12 c
.dbsym r temp_l 22 c
.dbsym r temp_h 10 c
.dbsym r Th 22 c
.dbsym r Tl 12 c
.dbend
.dbfunc e Temperature _Temperature fV
; tl_l -> R14,R15
; th_h -> R20,R21
; temp_negative -> R20,R21
; Tl -> R10
; Th -> R12
.even
_Temperature::
xcall push_xgset30FC
mov R10,R18
mov R12,R16
.dbline -1
.dbline 52
; }
; }
; /************************************************
; ************************************************/
; void Temperature(uint8_t Th,uint8_t Tl)
; {
.dbline 54
; uint16_t temp_negative,th_h,tl_l;
; if((Th&0x80)==0)//温度为正
sbrc R12,7
rjmp L71
X13:
.dbline 55
; {
.dbline 56
; LCD_set_xy(9,2);
ldi R18,2
ldi R16,9
xcall _LCD_set_xy
.dbline 57
; Positive();
.dbline 57
ldi R18,43
clr R16
xcall _LCD_write_byte
.dbline 57
.dbline 58
; Temp_display(Tl,Th);
mov R18,R12
mov R16,R10
xcall _Temp_display
.dbline 59
; }
xjmp L72
L71:
.dbline 61
; else //温度为负
; {
.dbline 62
; LCD_set_xy(9,2);
ldi R18,2
ldi R16,9
xcall _LCD_set_xy
.dbline 63
; Negative();
.dbline 63
ldi R18,45
clr R16
xcall _LCD_write_byte
.dbline 63
.dbline 64
; th_h=(uint16_t)Th;
mov R20,R12
clr R21
.dbline 65
; tl_l=(uint16_t)Tl;
mov R14,R10
clr R15
.dbline 66
; th_h<<=8;
mov R21,R20
clr R20
.dbline 67
; temp_negative=(th_h|tl_l);
or R20,R14
or R21,R15
.dbline 68
; temp_negative=~temp_negative+1;
com R20
com R21
subi R20,255 ; offset = 1
sbci R21,255
.dbline 69
; Tl=(uint8_t)temp_negative;
mov R10,R20
.dbline 70
; temp_negative>>=8;
mov R20,R21
clr R21
.dbline 71
; Th=(uint8_t)temp_negative;
mov R12,R20
.dbline 72
; Temp_display(Tl,Th);
mov R18,R12
mov R16,R10
xcall _Temp_display
.dbline 73
; }
L72:
.dbline -2
L70:
.dbline 0 ; func end
xjmp pop_xgset30FC
.dbsym r tl_l 14 i
.dbsym r th_h 20 i
.dbsym r temp_negative 20 i
.dbsym r Tl 10 c
.dbsym r Th 12 c
.dbend
.dbfunc e Delay_us _Delay_us fV
; us -> R16,R17
.even
_Delay_us::
.dbline -1
.dbline 83
; }
; /*************************************************
; 函 数 名:Delay_us
; 功 能:软件延时1.1us
; 入口参数:us 延时时间
; 出口参数:无
; 修改时间:2007.02.16
; *************************************************/
; void Delay_us(uint16_t us)
; {
xjmp L75
L74:
.dbline 85
; while(us>1)
; {
.dbline 86
; us--;
subi R16,1
sbci R17,0
.dbline 87
; }
L75:
.dbline 84
ldi R24,1
ldi R25,0
cp R24,R16
cpc R25,R17
brlo L74
X14:
.dbline -2
L73:
.dbline 0 ; func end
ret
.dbsym r us 16 i
.dbend
.dbfunc e Init_18b20 _Init_18b20 fc
; exist -> R20
.even
_Init_18b20::
st -y,R20
.dbline -1
.dbline 97
; }
; /*************************************************
; 函 数 名:Reset_18b20
; 功 能:复位DS18B20
; 入口参数:无
; 出口参数:exist : exist=1,存在;exist=0,不存在
; 修改日期:2007.02.16
; *************************************************/
; uint8_t Init_18b20(void)
; {
.dbline 98
; uint8_t exist=1;
ldi R20,1
.dbline 99
; Set_low(); //设置成输出模式
.dbline 99
sbi 0x11,7
.dbline 99
cbi 0x12,7
.dbline 99
.dbline 100
; Delay_us(600); //复位低电平480us~960us
ldi R16,600
ldi R17,2
xcall _Delay_us
.dbline 101
; Set_high(); //拉高电平
.dbline 101
sbi 0x11,7
.dbline 101
sbi 0x12,7
.dbline 101
.dbline 102
; Read(); //设置成输入模式
.dbline 102
cbi 0x11,7
.dbline 102
.dbline 103
; Delay_us(100); //延时100us
ldi R16,100
ldi R17,0
xcall _Delay_us
.dbline 104
; exist=~(DS18B20_PIN&DS18B20_IO); //读端口电平
in R20,0x10
andi R20,128
com R20
.dbline 105
; Delay_us(480); //延时480us
ldi R16,480
ldi R17,1
xcall _Delay_us
.dbline 106
; DDRA|=0X10; //设置成输出模式
sbi 0x1a,4
.dbline 107
; return (exist); //返回exist的值
mov R16,R20
.dbline -2
L77:
.dbline 0 ; func end
ld R20,y+
ret
.dbsym r exist 20 c
.dbend
.dbfunc e Read_1_byte _Read_1_byte fc
; r_data -> R10
; temp -> R22
; i -> R20
.even
_Read_1_byte::
xcall push_xgsetF00C
.dbline -1
.dbline 117
; }
; /*************************************************
; 函 数 名:Read_1_byte
; 功 能:从DS18B20读取一个字节的数据
; 入口参数:无
; 出口参数:r_data
; 修改日期:2007.02.16
; *************************************************/
; uint8_t Read_1_byte(void)
; {
.dbline 118
; uint8_t i,r_data=0x00,temp;
clr R10
.dbline 119
; for(i=0;i<8;i++)
clr R20
xjmp L82
L79:
.dbline 120
; {
.dbline 121
; Set_low();
.dbline 121
sbi 0x11,7
.dbline 121
cbi 0x12,7
.dbline 121
.dbline 122
; Delay_us(3);
ldi R16,3
ldi R17,0
xcall _Delay_us
.dbline 123
; Read();
.dbline 123
cbi 0x11,7
.dbline 123
.dbline 124
; Delay_us(8);
ldi R16,8
ldi R17,0
xcall _Delay_us
.dbline 125
; temp=(DS18B20_PIN&DS18B20_IO);
in R22,0x10
andi R22,128
.dbline 126
; if(temp)
breq L83
X15:
.dbline 127
; {
.dbline 128
; r_data|=(1<<i);
ldi R16,1
mov R17,R20
xcall lsl8
or R10,R16
.dbline 129
; }
xjmp L84
L83:
.dbline 131
; else
; {
.dbline 132
; r_data&=~(1<<i);
ldi R16,1
mov R17,R20
xcall lsl8
mov R2,R16
com R2
and R10,R2
.dbline 133
; }
L84:
.dbline 134
; Delay_us(50);
ldi R16,50
ldi R17,0
xcall _Delay_us
.dbline 135
; Set_high();
.dbline 135
sbi 0x11,7
.dbline 135
sbi 0x12,7
.dbline 135
.dbline 136
; }
L80:
.dbline 119
inc R20
L82:
.dbline 119
cpi R20,8
brlo L79
X16:
.dbline 137
; return (r_data);
mov R16,R10
.dbline -2
L78:
.dbline 0 ; func end
xjmp pop_xgsetF00C
.dbsym r r_data 10 c
.dbsym r temp 22 c
.dbsym r i 20 c
.dbend
.dbfunc e Write_1_byte _Write_1_byte fV
; temp -> R22
; i -> R20
; cmd -> R10
.even
_Write_1_byte::
xcall push_xgsetF00C
mov R10,R16
.dbline -1
.dbline 147
; }
; /*************************************************
; 函 数 名:Write_1_byte
; 功 能:写一个字节到DS18B20
; 入口参数:cmd
; 出口参数:无
; 修改日期:2007.02.16
; *************************************************/
; void Write_1_byte(uint8_t cmd)
; {
.dbline 149
; uint8_t i,temp;
; for(i=0;i<8;i++)
clr R20
xjmp L89
L86:
.dbline 150
; {
.dbline 151
; temp=(cmd>>i);
mov R16,R10
mov R17,R20
xcall lsr8
mov R22,R16
.dbline 152
; temp&=0x01;
andi R22,1
.dbline 153
; if(temp)
breq L90
X17:
.dbline 154
; {
.dbline 155
; Write_1();
xcall _Write_1
.dbline 156
; }
xjmp L91
L90:
.dbline 158
; else
; {
.dbline 159
; Write_0();
xcall _Write_0
.dbline 160
; }
L91:
.dbline 161
; }
L87:
.dbline 149
inc R20
L89:
.dbline 149
cpi R20,8
brlo L86
X18:
.dbline -2
L85:
.dbline 0 ; func end
xjmp pop_xgsetF00C
.dbsym r temp 22 c
.dbsym r i 20 c
.dbsym r cmd 10 c
.dbend
.dbfunc e Write_1 _Write_1 fV
.even
_Write_1::
.dbline -1
.dbline 171
; }
; /************************************************
; 函 数 名:Write_1
; 功 能:写一个Bit到DS18B20
; 入口参数:无
; 出口参数:无
; 修改日期:2007.02.16
; ************************************************/
; void Write_1(void)
; {
.dbline 172
; Set_low(); //设置成输出模式
.dbline 172
sbi 0x11,7
.dbline 172
cbi 0x12,7
.dbline 172
.dbline 173
; Delay_us(4);
ldi R16,4
ldi R17,0
xcall _Delay_us
.dbline 174
; Set_high();
.dbline 174
sbi 0x11,7
.dbline 174
sbi 0x12,7
.dbline 174
.dbline 175
; Delay_us(76);
ldi R16,76
ldi R17,0
xcall _Delay_us
.dbline -2
L92:
.dbline 0 ; func end
ret
.dbend
.dbfunc e Write_0 _Write_0 fV
.even
_Write_0::
.dbline -1
.dbline 185
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -