📄 lcd-16sn.s
字号:
L16:
.dbline 110
; else if(cursor_index==0x50)
lds R24,_cursor_index
lds R25,_cursor_index+1
cpi R24,80
ldi R30,0
cpc R25,R30
brne L18
X3:
.dbline 111
; cursor_line1();
xcall _cursor_line1
L18:
L17:
.dbline 112
; wr_data(data);
mov R16,R10
xcall _wr_data
.dbline 113
; cursor_index++;
lds R24,_cursor_index
lds R25,_cursor_index+1
adiw R24,1
sts _cursor_index+1,R25
sts _cursor_index,R24
.dbline 114
; delay(50);
ldi R16,50
ldi R17,0
xcall _delay
.dbline -2
L15:
.dbline 0 ; func end
ld R10,y+
ret
.dbsym l flags 1 c
.dbsym r data 10 c
.dbend
.dbfunc e cursor_home _cursor_home fV
.even
_cursor_home::
.dbline -1
.dbline 118
; }
;
; void cursor_home(void) //Move cursor to Home
; {
.dbline 119
; wr_instruction2(0x01);
ldi R16,1
xcall _wr_instruction2
.dbline 120
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline 121
; wr_instruction2(0x80);
ldi R16,128
xcall _wr_instruction2
.dbline 122
; ldelay(5);
ldi R16,5
ldi R17,0
xcall _ldelay
.dbline 123
; cursor_index=0;
clr R2
clr R3
sts _cursor_index+1,R3
sts _cursor_index,R2
.dbline -2
L20:
.dbline 0 ; func end
ret
.dbend
.dbfunc e cursor_line1 _cursor_line1 fV
.even
_cursor_line1::
.dbline -1
.dbline 127
; }
;
; void cursor_line1(void) //Move cursor to the first line
; {
.dbline 128
; wr_instruction2(0x80);
ldi R16,128
xcall _wr_instruction2
.dbline 129
; cursor_index=0;
clr R2
clr R3
sts _cursor_index+1,R3
sts _cursor_index,R2
.dbline 130
; ldelay(5);
ldi R16,5
ldi R17,0
xcall _ldelay
.dbline -2
L21:
.dbline 0 ; func end
ret
.dbend
.dbfunc e cursor_line2 _cursor_line2 fV
.even
_cursor_line2::
.dbline -1
.dbline 134
; }
;
; void cursor_line2(void) //Move cursor to the second line
; {
.dbline 135
; wr_instruction2(0b11000000);
ldi R16,192
xcall _wr_instruction2
.dbline 136
; cursor_index=0x40;
ldi R24,64
ldi R25,0
sts _cursor_index+1,R25
sts _cursor_index,R24
.dbline 137
; ldelay(2);
ldi R16,2
ldi R17,0
xcall _ldelay
.dbline -2
L22:
.dbline 0 ; func end
ret
.dbend
.dbfunc e space _space fV
.even
_space::
.dbline -1
.dbline 141
; }
;
; void space(void) //Write space, ' ', on the panel
; {
.dbline 142
; wr_data2(' ');
ldi R16,32
xcall _wr_data2
.dbline -2
L23:
.dbline 0 ; func end
ret
.dbend
.dbfunc e clear_line1 _clear_line1 fV
; i -> R20,R21
.even
_clear_line1::
st -y,R20
st -y,R21
.dbline -1
.dbline 146
; }
;
; void clear_line1(void)
; {
.dbline 148
; int i;
; cursor_line1();
xcall _cursor_line1
.dbline 149
; for(i=0; i<=15; i++)
clr R20
clr R21
L25:
.dbline 150
; space();
xcall _space
L26:
.dbline 149
subi R20,255 ; offset = 1
sbci R21,255
.dbline 149
ldi R24,15
ldi R25,0
cp R24,R20
cpc R25,R21
brge L25
X4:
.dbline 151
; cursor_line1();
xcall _cursor_line1
.dbline -2
L24:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r i 20 I
.dbend
.dbfunc e clear_line2 _clear_line2 fV
; i -> R20,R21
.even
_clear_line2::
st -y,R20
st -y,R21
.dbline -1
.dbline 155
; }
;
; void clear_line2(void)
; {
.dbline 157
; int i;
; cursor_line2();
xcall _cursor_line2
.dbline 158
; for(i=0; i<=15; i++)
clr R20
clr R21
L30:
.dbline 159
; space();
xcall _space
L31:
.dbline 158
subi R20,255 ; offset = 1
sbci R21,255
.dbline 158
ldi R24,15
ldi R25,0
cp R24,R20
cpc R25,R21
brge L30
X5:
.dbline 160
; cursor_line2();
xcall _cursor_line2
.dbline -2
L29:
.dbline 0 ; func end
ld R21,y+
ld R20,y+
ret
.dbsym r i 20 I
.dbend
.dbfunc e out_string _out_string fV
; onechar -> R12
; i -> R20,R21
; array -> R10,R11
.even
_out_string::
xcall push_xgset303C
movw R10,R16
.dbline -1
.dbline 165
; }
;
;
; void out_string(const char array[]) //Send a string stored in array to LCD panel
; {
.dbline 166
; int i=0;
clr R20
clr R21
.dbline 168
; unsigned char onechar;
; i=0;
xjmp L36
L35:
.dbline 170
; while(array[i])
; {
.dbline 171
; onechar=array[i++];
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
movw R30,R2
add R30,R10
adc R31,R11
elpm R12,Z
.dbline 172
; wr_data2(onechar);
mov R16,R12
xcall _wr_data2
.dbline 173
; }
L36:
.dbline 169
movw R30,R20
add R30,R10
adc R31,R11
elpm R2,Z
tst R2
brne L35
X6:
.dbline -2
L34:
.dbline 0 ; func end
xjmp pop_xgset303C
.dbsym r onechar 12 c
.dbsym r i 20 I
.dbsym r array 10 pkc
.dbend
.dbfunc e lcd_on _lcd_on fV
; ctrl_data -> <dead>
; i -> <dead>
.even
_lcd_on::
.dbline -1
.dbline 177
; }
;
; void lcd_on(void)
; {
.dbline 179
; unsigned char i, ctrl_data;
; ldelay(20);
ldi R16,20
ldi R17,0
xcall _ldelay
.dbline 180
; PORTD=0x01;
ldi R24,1
out 0x12,R24
.dbline 181
; ldelay(40);
ldi R16,40
ldi R17,0
xcall _ldelay
.dbline 182
; wr_instruction(0b00110000); //Function Set:set 8-bit, 2line, 5x7 fonts
ldi R16,48
xcall _wr_instruction
.dbline 183
; ldelay(2);
ldi R16,2
ldi R17,0
xcall _ldelay
.dbline 184
; wr_instruction(0b00110000); //
ldi R16,48
xcall _wr_instruction
.dbline 185
; ldelay(2);
ldi R16,2
ldi R17,0
xcall _ldelay
.dbline 186
; wr_instruction(0b00110000); //
ldi R16,48
xcall _wr_instruction
.dbline 187
; delay(80);
ldi R16,80
ldi R17,0
xcall _delay
.dbline 188
; wr_instruction(0b00111100); //8-bit, 2 lines, 5x7 font
ldi R16,60
xcall _wr_instruction
.dbline 189
; delay(20);
ldi R16,20
ldi R17,0
xcall _delay
.dbline 190
; wr_instruction(0b00001110); //display on, cursor on, blink off
ldi R16,14
xcall _wr_instruction
.dbline 191
; delay(20);
ldi R16,20
ldi R17,0
xcall _delay
.dbline 192
; wr_instruction(0b00001110); //display on,
ldi R16,14
xcall _wr_instruction
.dbline 193
; delay(20);
ldi R16,20
ldi R17,0
xcall _delay
.dbline 194
; wr_instruction(0b00000001); //clear display
ldi R16,1
xcall _wr_instruction
.dbline 195
; ldelay(5);
ldi R16,5
ldi R17,0
xcall _ldelay
.dbline 196
; wr_instruction(0b00000110); //Entry mode
ldi R16,6
xcall _wr_instruction
.dbline 197
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline 198
; wr_instruction(0b00000001); //clear display
ldi R16,1
xcall _wr_instruction
.dbline 199
; delay(20);
ldi R16,20
ldi R17,0
xcall _delay
.dbline -2
L38:
.dbline 0 ; func end
ret
.dbsym l ctrl_data 1 c
.dbsym l i 1 c
.dbend
.area bss(ram, con, rel)
.dbfile C:\+samples-16small\DEMOB-16sm\LCD-16sn.c
_swin2::
.blkb 1
.dbsym e swin2 _swin2 c
_swin::
.blkb 1
.dbsym e swin _swin c
_indexcount::
.blkb 2
.dbsym e indexcount _indexcount I
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -