📄 lcd.s
字号:
.dbline 152
; lcd_set_rs(); // Set LCD to data
sbi 0x18,0
.dbline 153
; lcd_set_e(); // Write data to LCD
sbi 0x18,2
.dbline 154
; asm("nop");
nop
.dbline 155
; asm("nop");
nop
.dbline 156
; lcd_clear_e(); // Disable LCD
cbi 0x18,2
.dbline -2
L7:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r temp 20 c
.dbsym r Data 22 c
.dbend
.dbfunc e Init_LCD _Init_LCD fV
.even
_Init_LCD::
.dbline -1
.dbline 162
; }
; // ********************************* //
; // *** Initialize the LCD driver *** //
; // ********************************* //
; void Init_LCD(void)
; {
.dbline 163
; LCD_INIT();
xcall _LCD_INIT
.dbline 164
; LCD_WriteControl (LCD_FUNCTION_SET);
ldi R16,40
xcall _LCD_WriteControl
.dbline 165
; LCD_WriteControl (LCD_OFF);
ldi R16,8
xcall _LCD_WriteControl
.dbline 166
; LCD_WriteControl (LCD_CLEAR);
ldi R16,1
xcall _LCD_WriteControl
.dbline 167
; LCD_WriteControl (LCD_MODE_SET);
ldi R16,6
xcall _LCD_WriteControl
.dbline 168
; LCD_WriteControl (LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline 169
; LCD_WriteControl (LCD_HOME);
ldi R16,2
xcall _LCD_WriteControl
.dbline -2
L8:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Clear _LCD_Clear fV
.even
_LCD_Clear::
.dbline -1
.dbline 175
; }
; // ************************************************ //
; // *** Clear the LCD screen (also homes cursor) *** //
; // ************************************************ //
; void LCD_Clear(void)
; {
.dbline 176
; LCD_WriteControl(0x01);
ldi R16,1
xcall _LCD_WriteControl
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Home _LCD_Home fV
.even
_LCD_Home::
.dbline -1
.dbline 182
; }
; // *********************************************** //
; // *** Position the LCD cursor at row 1, col 1 *** //
; // *********************************************** //
; void LCD_Home(void)
; {
.dbline 183
; LCD_WriteControl(0x02);
ldi R16,2
xcall _LCD_WriteControl
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_DisplayCharacter _LCD_DisplayCharacter fV
; Char -> R20
.even
_LCD_DisplayCharacter::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 189
; }
; // ****************************************************************** //
; // *** Display a single character, at the current cursor location *** //
; // ****************************************************************** //
; void LCD_DisplayCharacter (char Char)
; {
.dbline 190
; LCD_WriteData (Char);
mov R16,R20
xcall _LCD_WriteData
.dbline -2
L11:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Char 20 c
.dbend
.dbfunc e LCD_DisplayString_F _LCD_DisplayString_F fV
; string -> R20,R21
; column -> R10
; row -> R22
.even
_LCD_DisplayString_F::
xcall push_gset3
mov R10,R18
mov R22,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 196
; }
; // ********************************************************************* //
; // *** Display a string at the specified row and column, using FLASH *** //
; // ********************************************************************* //
; void LCD_DisplayString_F (char row, char column , unsigned char *string)
; {
.dbline 197
; LCD_Cursor (row, column);
mov R18,R10
mov R16,R22
xcall _LCD_Cursor
xjmp L14
L13:
.dbline 199
.dbline 200
movw R30,R20
ld R16,Z+
movw R20,R30
xcall _LCD_DisplayCharacter
.dbline 201
L14:
.dbline 198
; while (*string)
movw R30,R20
ldd R2,z+0
tst R2
brne L13
.dbline -2
L12:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r string 20 pc
.dbsym r column 10 c
.dbsym r row 22 c
.dbend
.dbfunc e LCD_DisplayString _LCD_DisplayString fV
; string -> R20,R21
; column -> R10
; row -> R22
.even
_LCD_DisplayString::
xcall push_gset3
mov R10,R18
mov R22,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 207
; {
; LCD_DisplayCharacter (*string++);
; }
; }
; // ******************************************************************* //
; // *** Display a string at the specified row and column, using RAM *** //
; // ******************************************************************* //
; void LCD_DisplayString (char row, char column ,unsigned char *string)
; {
.dbline 208
; LCD_Cursor (row, column);
mov R18,R10
mov R16,R22
xcall _LCD_Cursor
xjmp L18
L17:
.dbline 210
movw R30,R20
ld R16,Z+
movw R20,R30
xcall _LCD_DisplayCharacter
L18:
.dbline 209
; while (*string)
movw R30,R20
ldd R2,z+0
tst R2
brne L17
.dbline -2
L16:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r string 20 pc
.dbsym r column 10 c
.dbsym r row 22 c
.dbend
.dbfunc e LCD_Cursor _LCD_Cursor fV
; column -> R20
; row -> R22
.even
_LCD_Cursor::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 216
; LCD_DisplayCharacter (*string++);
; }
; // *************************************************** //
; // *** Position the LCD cursor at "row", "column". *** //
; // *************************************************** //
; void LCD_Cursor (char row, char column)
; {
.dbline 217
clr R23
cpi R22,1
ldi R30,0
cpc R23,R30
breq L24
cpi R22,2
ldi R30,0
cpc R23,R30
breq L25
cpi R22,3
ldi R30,0
cpc R23,R30
breq L26
cpi R22,4
ldi R30,0
cpc R23,R30
breq L27
xjmp L22
X0:
.dbline 217
; switch (row) {
L24:
.dbline 218
; case 1: LCD_WriteControl (0x80 + column - 1); break;
mov R16,R20
subi R16,128 ; addi 128
subi R16,1
xcall _LCD_WriteControl
.dbline 218
xjmp L22
L25:
.dbline 219
; case 2: LCD_WriteControl (0xc0 + column - 1); break;
mov R16,R20
subi R16,64 ; addi 192
subi R16,1
xcall _LCD_WriteControl
.dbline 219
xjmp L22
L26:
.dbline 220
; case 3: LCD_WriteControl (0x94 + column - 1); break;
mov R16,R20
subi R16,108 ; addi 148
subi R16,1
xcall _LCD_WriteControl
.dbline 220
xjmp L22
L27:
.dbline 221
mov R16,R20
subi R16,44 ; addi 212
subi R16,1
xcall _LCD_WriteControl
.dbline 221
.dbline 222
L22:
.dbline -2
L20:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r column 20 c
.dbsym r row 22 c
.dbend
.dbfunc e LCD_Cursor_On _LCD_Cursor_On fV
.even
_LCD_Cursor_On::
.dbline -1
.dbline 229
; case 4: LCD_WriteControl (0xd4 + column - 1); break;
; default: break;
; }
; }
; // ************************** //
; // *** Turn the cursor on *** //
; // ************************** //
; void LCD_Cursor_On (void)
; {
.dbline 230
; LCD_WriteControl (LCD_CURS_ON);
ldi R16,13
xcall _LCD_WriteControl
.dbline -2
L28:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Cursor_Off _LCD_Cursor_Off fV
.even
_LCD_Cursor_Off::
.dbline -1
.dbline 236
; }
; // *************************** //
; // *** Turn the cursor off *** //
; // *************************** //
; void LCD_Cursor_Off (void)
; {
.dbline 237
; LCD_WriteControl (LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline -2
L29:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Display_Off _LCD_Display_Off fV
.even
_LCD_Display_Off::
.dbline -1
.dbline 243
; }
; // ******************** //
; // *** Turn Off LCD *** //
; // ******************** //
; void LCD_Display_Off (void)
; {
.dbline 244
; LCD_WriteControl(LCD_OFF);
ldi R16,8
xcall _LCD_WriteControl
.dbline -2
L30:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_Display_On _LCD_Display_On fV
.even
_LCD_Display_On::
.dbline -1
.dbline 250
; }
; // ******************* //
; // *** Turn On LCD *** //
; // ******************* //
; void LCD_Display_On (void)
; {
.dbline 251
; LCD_WriteControl(LCD_ON);
ldi R16,12
xcall _LCD_WriteControl
.dbline -2
L31:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -