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

📄 lcd.s

📁 ATMEGA128控制4×6矩阵键盘,LCD1602 使用protues软件可仿真 附带图片可观看效果
💻 S
📖 第 1 页 / 共 2 页
字号:
	nop
	.dbline 148
; asm("nop");
	nop
	.dbline 149
; lcd_clear_e(); // Disable LCD
	cbi 0x12,2
	.dbline 150
; LCD_OP_PORT = (Data << 4)|temp; // Load low-data to port
	mov R24,R22
	andi R24,#0x0F
	swap R24
	or R24,R20
	out 0x12,R24
	.dbline 151
; lcd_clear_rw() ; // Set LCD to write
	cbi 0x12,1
	.dbline 152
; lcd_set_rs(); // Set LCD to data
	sbi 0x12,0
	.dbline 153
; lcd_set_e(); // Write data to LCD
	sbi 0x12,2
	.dbline 154
; asm("nop");
	nop
	.dbline 155
; asm("nop");
	nop
	.dbline 156
; lcd_clear_e(); // Disable LCD
	cbi 0x12,2
	.dbline -2
L7:
	.dbline 0 ; func end
	ld R22,y+
	ld R20,y+
	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 177
; //LCD_WriteControl (0x90);
; 
; }
; // ************************************************ //
; // *** Clear the LCD screen (also homes cursor) *** //
; // ************************************************ //
; void LCD_Clear(void)
; {
	.dbline 178
; 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 184
; }
; // *********************************************** //
; // *** Position the LCD cursor at row 1, col 1 *** //
; // *********************************************** //
; void LCD_Home(void)
; {
	.dbline 185
; 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 -> R10
	.even
_LCD_DisplayCharacter::
	st -y,R10
	mov R10,R16
	.dbline -1
	.dbline 191
; }
; // ****************************************************************** //
; // *** Display a single character, at the current cursor location *** //
; // ****************************************************************** //
; void LCD_DisplayCharacter (char Char)
; {
	.dbline 192
; LCD_WriteData (Char);
	mov R16,R10
	xcall _LCD_WriteData
	.dbline -2
L11:
	.dbline 0 ; func end
	ld R10,y+
	ret
	.dbsym r Char 10 c
	.dbend
	.dbfunc e LCD_DisplayString _LCD_DisplayString fV
;         string -> R10,R11
;         column -> R14
;            row -> R12
	.even
_LCD_DisplayString::
	xcall push_xgset00FC
	mov R14,R18
	mov R12,R16
	ldd R10,y+6
	ldd R11,y+7
	.dbline -1
	.dbline 211
; }
; // ********************************************************************* //
; // *** Display a string at the specified row and column, using FLASH *** //
; // ********************************************************************* //
; /*
; void LCD_DisplayString_F (char row, char column , unsigned char __flash *string)
; {
; LCD_Cursor (row, column);
; while (*string)
; {
; 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 212
; LCD_Cursor (row, column);
	mov R18,R14
	mov R16,R12
	xcall _LCD_Cursor
	xjmp L14
L13:
	.dbline 214
; while (*string)
; LCD_DisplayCharacter (*string++);
	movw R30,R10
	ld R16,Z+
	movw R10,R30
	xcall _LCD_DisplayCharacter
L14:
	.dbline 213
	movw R30,R10
	ldd R2,z+0
	tst R2
	brne L13
X1:
	.dbline -2
L12:
	.dbline 0 ; func end
	xjmp pop_xgset00FC
	.dbsym r string 10 pc
	.dbsym r column 14 c
	.dbsym r row 12 c
	.dbend
	.dbfunc e LCD_Cursor _LCD_Cursor fV
;         column -> R20
;            row -> R10
	.even
_LCD_Cursor::
	xcall push_xgsetF00C
	mov R20,R18
	mov R10,R16
	.dbline -1
	.dbline 220
; }
; // *************************************************** //
; // *** Position the LCD cursor at "row", "column". *** //
; // *************************************************** //
; void LCD_Cursor (char row, char column)
; {
	.dbline 221
; switch (row) {
	mov R22,R10
	clr R23
	cpi R22,1
	ldi R30,0
	cpc R23,R30
	breq L20
X2:
	cpi R22,2
	ldi R30,0
	cpc R23,R30
	breq L21
X3:
	cpi R22,3
	ldi R30,0
	cpc R23,R30
	breq L22
X4:
	cpi R22,4
	ldi R30,0
	cpc R23,R30
	breq L23
X5:
	xjmp L18
L20:
	.dbline 222
; case 1: LCD_WriteControl (0x80 + column - 1); break;
	mov R16,R20
	subi R16,128    ; addi 128
	subi R16,1
	xcall _LCD_WriteControl
	.dbline 222
	xjmp L18
L21:
	.dbline 223
; case 2: LCD_WriteControl (0xc0 + column - 1); break;
	mov R16,R20
	subi R16,64    ; addi 192
	subi R16,1
	xcall _LCD_WriteControl
	.dbline 223
	xjmp L18
L22:
	.dbline 224
; case 3: LCD_WriteControl (0x94 + column - 1); break;
	mov R16,R20
	subi R16,108    ; addi 148
	subi R16,1
	xcall _LCD_WriteControl
	.dbline 224
	xjmp L18
L23:
	.dbline 225
; case 4: LCD_WriteControl (0xd4 + column - 1); break;
	mov R16,R20
	subi R16,44    ; addi 212
	subi R16,1
	xcall _LCD_WriteControl
	.dbline 225
	.dbline 226
; default: break;
L18:
	.dbline -2
L16:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
	.dbsym r column 20 c
	.dbsym r row 10 c
	.dbend
	.dbfunc e LCD_Cursor_On _LCD_Cursor_On fV
	.even
_LCD_Cursor_On::
	.dbline -1
	.dbline 233
; }
; }
; // ************************** //
; // *** Turn the cursor on *** //
; // ************************** //
; void LCD_Cursor_On (void)
; {
	.dbline 234
; LCD_WriteControl (LCD_CURS_ON);
	ldi R16,13
	xcall _LCD_WriteControl
	.dbline -2
L24:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_Cursor_Off _LCD_Cursor_Off fV
	.even
_LCD_Cursor_Off::
	.dbline -1
	.dbline 240
; }
; // *************************** //
; // *** Turn the cursor off *** //
; // *************************** //
; void LCD_Cursor_Off (void)
; {
	.dbline 241
; LCD_WriteControl (LCD_ON);
	ldi R16,12
	xcall _LCD_WriteControl
	.dbline -2
L25:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_Display_Off _LCD_Display_Off fV
	.even
_LCD_Display_Off::
	.dbline -1
	.dbline 247
; }
; // ******************** //
; // *** Turn Off LCD *** //
; // ******************** //
; void LCD_Display_Off (void)
; {
	.dbline 248
; LCD_WriteControl(LCD_OFF);
	ldi R16,8
	xcall _LCD_WriteControl
	.dbline -2
L26:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_Display_On _LCD_Display_On fV
	.even
_LCD_Display_On::
	.dbline -1
	.dbline 254
; }
; // ******************* //
; // *** Turn On LCD *** //
; // ******************* //
; void LCD_Display_On (void)
; {
	.dbline 255
; LCD_WriteControl(LCD_ON);
	ldi R16,12
	xcall _LCD_WriteControl
	.dbline -2
L27:
	.dbline 0 ; func end
	ret
	.dbend
; }

⌨️ 快捷键说明

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