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

📄 ks0108_12864lcd.s

📁 ks0108 avr单片机1284显示
💻 S
📖 第 1 页 / 共 3 页
字号:
	.dbline 166
	subi R22,255  ; offset = 1
	sbci R23,255
L39:
	.dbline 166
	cpi R22,144
	ldi R30,1
	cpc R23,R30
	brlo L36
X7:
L33:
	.dbline 165
	subi R20,255  ; offset = 1
	sbci R21,255
L35:
	.dbline 165
	cpi R20,232
	ldi R30,3
	cpc R21,R30
	brlo L32
X8:
	.dbline -2
L7:
	.dbline 0 ; func end
	adiw R28,11
	xjmp pop_xgsetF000
	.dbsym r i 20 s
	.dbsym r j 22 s
	.dbend
	.dbfunc s Clear_Screen _Clear_Screen fV
;           Page -> R20
;         Column -> R22
;     Vedio_Mode -> R10
	.even
_Clear_Screen:
	xcall push_xgsetF00C
	mov R10,R16
	sbiw R28,1
	.dbline -1
	.dbline 177
;    }
; 
; /*----------------------------------------------------------------------------*-
; 
;    Clear_Screen()
; 
;    This function clears the LCD screen.
; 
; -*----------------------------------------------------------------------------*/    
; static void Clear_Screen(uInt8 Vedio_Mode)
;    {   
	.dbline 180
;    uInt8 Page, Column;
;    
;    for (Page = 0; Page < 8; Page++) // Clear left side
	clr R20
	xjmp L44
L41:
	.dbline 181
;       {
	.dbline 182
;       LCD_INSTR_PORT |=  LCD_CS1; // Select left side
	sbi 0x12,4
	.dbline 183
;       LCD_INSTR_PORT &= ~LCD_CS2;
	cbi 0x12,5
	.dbline 185
; 
;       LCD_Send_Byte(DISPLAY_PAGE_SET + Page, COMMAND, NORMAL); // Sweep pages
	clr R2
	std y+0,R2
	clr R18
	mov R16,R20
	subi R16,72    ; addi 184
	xcall _LCD_Send_Byte
	.dbline 186
;       LCD_Send_Byte(DISPLAY_COLUMN_SET, COMMAND, NORMAL);
	clr R2
	std y+0,R2
	clr R18
	ldi R16,64
	xcall _LCD_Send_Byte
	.dbline 188
; 	  
;       for (Column = 0; Column < 128; Column++)
	clr R22
	xjmp L48
L45:
	.dbline 189
;          { 
	.dbline 191
; 		 // Clear right side
;          if(Column == 64)
	cpi R22,64
	brne L49
X9:
	.dbline 192
;             {
	.dbline 193
;             LCD_INSTR_PORT &= ~LCD_CS1; // Select right side
	cbi 0x12,4
	.dbline 194
;             LCD_INSTR_PORT |=  LCD_CS2;
	sbi 0x12,5
	.dbline 197
; 			
; 			// Sweep pages
;             LCD_Send_Byte(DISPLAY_PAGE_SET + Page, COMMAND, NORMAL); 
	clr R2
	std y+0,R2
	clr R18
	mov R16,R20
	subi R16,72    ; addi 184
	xcall _LCD_Send_Byte
	.dbline 198
;             LCD_Send_Byte(DISPLAY_COLUMN_SET, COMMAND, NORMAL);
	clr R2
	std y+0,R2
	clr R18
	ldi R16,64
	xcall _LCD_Send_Byte
	.dbline 199
;             }
L49:
	.dbline 201
; 		 // For each set of 8 pixels, write 0x00 or 0xFF(depend on Vedio_Mode)
;          LCD_Send_Byte(0x00, D_DATA, Vedio_Mode); 
	std y+0,R10
	ldi R18,1
	clr R16
	xcall _LCD_Send_Byte
	.dbline 202
;          }
L46:
	.dbline 188
	inc R22
L48:
	.dbline 188
	cpi R22,128
	brlo L45
X10:
	.dbline 203
;       }
L42:
	.dbline 180
	inc R20
L44:
	.dbline 180
	cpi R20,8
	brlo L41
X11:
	.dbline -2
L40:
	.dbline 0 ; func end
	adiw R28,1
	xjmp pop_xgsetF00C
	.dbsym r Page 20 c
	.dbsym r Column 22 c
	.dbsym r Vedio_Mode 10 c
	.dbend
	.dbfunc s LCD_Read_Busy _LCD_Read_Busy fV
;    LCD_Timeout -> R16,R17
	.even
_LCD_Read_Busy:
	.dbline -1
	.dbline 214
;    }
; 
; /*----------------------------------------------------------------------------*-
; 
;    LCD_Read_Busy()    
;  
;    Check out if the LCD is in operation or ready for writing data.
; 			   
; -*----------------------------------------------------------------------------*/
; static void LCD_Read_Busy(void)
;    {
	.dbline 217
;    uInt16 LCD_Timeout; // Software timeout 
;    
;    LCD_DATA_PORT = 0xFF;  
	ldi R24,255
	out 0x1b,R24
	.dbline 218
;    LCD_DATA_PORT_DIR = INPUT; // Set data PORT direction 
	clr R2
	out 0x1a,R2
	.dbline 220
;  
;    LCD_INSTR_PORT &= ~LCD_DI; // Set instruction
	cbi 0x12,0
	.dbline 221
;    LCD_INSTR_PORT |=  LCD_RW; // Set read
	sbi 0x12,1
	.dbline 223
; 
;    LCD_INSTR_PORT |=  LCD_EN;
	sbi 0x12,2
	.dbline 224
;    asm("nop");	
	nop
	.dbline 225
;    asm("nop");
	nop
	.dbline 227
;     
;    LCD_INSTR_PORT &= ~LCD_EN; // Toggle enable
	cbi 0x12,2
	.dbline 228
;    asm("nop");	
	nop
	.dbline 229
;    asm("nop");
	nop
	xjmp L53
L52:
	.dbline 233
;    
;    // See if busy with software timeout       
;    while((LCD_BUSY & LCD_DATA_PORT_VL) && ++LCD_Timeout)  
;       {
	.dbline 234
;       LCD_INSTR_PORT &= ~LCD_EN; // Toggle enable   		
	cbi 0x12,2
	.dbline 235
;       asm("nop");	
	nop
	.dbline 236
; 	  asm("nop");
	nop
	.dbline 238
; 	  
;       LCD_INSTR_PORT |=  LCD_EN;
	sbi 0x12,2
	.dbline 239
;       asm("nop");	
	nop
	.dbline 240
; 	  asm("nop");
	nop
	.dbline 241
;       }
L53:
	.dbline 232
	sbis 0x19,7
	rjmp L55
X12:
	movw R24,R16
	adiw R24,1
	movw R16,R24
	cpi R24,0
	cpc R24,R25
	brne L52
X13:
L55:
	.dbline 242
;    LCD_DATA_PORT_DIR = OUTPUT; // Set data PORT direction back to an output
	ldi R24,255
	out 0x1a,R24
	.dbline 243
;    LCD_INSTR_PORT &= ~LCD_EN;
	cbi 0x12,2
	.dbline -2
L51:
	.dbline 0 ; func end
	ret
	.dbsym r LCD_Timeout 16 s
	.dbend
	.dbfunc s LCD_Send_Byte _LCD_Send_Byte fV
;         IVERSE -> y+0
;      DATA_FLAG -> R18
;           DATA -> R16
	.even
_LCD_Send_Byte:
	.dbline -1
	.dbline 264
;    }     
;    
; /*----------------------------------------------------------------------------*-
; 
;    LCD_Send_Byte()
; 
;    This function writes a byte to the LCD panel.
; 
;    Parameters: 
;    ---------------------------------------------------------------------------
;    Data      : The byte to be written to the LCD
;     
;    DATA_FLAG : If DATA_FLAG == 1, a data byte is sent
;                If DATA_FLAG == 0, a command byte is sent
; 			  
;    IVERSE    : If IVERSE == 1, inverse video mode			   
;                If IVERSE == 0, normal video mode
; 			  
; -*----------------------------------------------------------------------------*/
; static void LCD_Send_Byte(uInt8 DATA, uInt8 DATA_FLAG, uInt8 IVERSE)
;    { 
	.dbline 267
;    // LCD_Read_Busy();
;      
;    LCD_INSTR_PORT |=  LCD_EN;
	sbi 0x12,2
	.dbline 268
;    asm("nop");	
	nop
	.dbline 269
;    asm("nop");
	nop
	.dbline 271
;    
;    if (DATA_FLAG)
	tst R18
	breq L57
X14:
	.dbline 272
;       LCD_INSTR_PORT |=  LCD_DI; // Set data   
	sbi 0x12,0
	xjmp L58
L57:
	.dbline 274
;    else
;       LCD_INSTR_PORT &= ~LCD_DI; // Set instruction
	cbi 0x12,0
L58:
	.dbline 276
; 
;    LCD_INSTR_PORT &= ~LCD_RW; // Set write
	cbi 0x12,1
	.dbline 278
;    
;    if (IVERSE && DATA_FLAG)   
	ldd R0,y+0
	tst R0
	breq L59
X15:
	tst R18
	breq L59
X16:
	.dbline 279
;       LCD_DATA_PORT = 255 - DATA; // Send inverse data
	mov R2,R16
	clr R3
	ldi R24,255
	ldi R25,0
	sub R24,R2
	sbc R25,R3
	out 0x1b,R24
	xjmp L60
L59:
	.dbline 281
;    else
;       LCD_DATA_PORT = DATA; // Send data or instruction
	out 0x1b,R16
L60:
	.dbline 283
;    
;    LCD_INSTR_PORT &= ~LCD_EN; // Toggle enable
	cbi 0x12,2
	.dbline 284
;    asm("nop");	
	nop
	.dbline 285
;    asm("nop");
	nop
	.dbline -2
L56:
	.dbline 0 ; func end
	ret
	.dbsym l IVERSE 0 c
	.dbsym r DATA_FLAG 18 c
	.dbsym r DATA 16 c
	.dbend
	.dbfunc s LCD_Set_XY _LCD_Set_XY fV
;              Y -> R20
;              X -> R22
	.even
_LCD_Set_XY:
	st -y,R20
	st -y,R22
	mov R20,R18
	mov R22,R16
	sbiw R28,1
	.dbline -1
	.dbline 303
;    }
; 
; /*----------------------------------------------------------------------------*-
;   
;    LCD_Set_XY()
; 
;    Set the DDRAM to a particular address.
; 
;    Used to determine where we write to in the LCD RAM and - thus -
;    whether the text appears on Page 0, page 1, Column 0, Column 1, etc.
; 
;    Params (X, Y) : The DDRAM address we wish to write to. 
;    
;    X range : (Page 0 ~ Page 7), Y range : (0 ~ 127)
; 
; -*----------------------------------------------------------------------------*/
; static void LCD_Set_XY(uInt8 X, uInt8 Y)
;    {
	.dbline 304
;    if (Y >= 64)
	cpi R20,64
	brlo L62
X17:
	.dbline 305
;       {
	.dbline 306
;       LCD_INSTR_PORT &= ~LCD_CS1; // Select right side
	cbi 0x12,4
	.dbline 307
;       LCD_INSTR_PORT |=  LCD_CS2;
	sbi 0x12,5
	.dbline 308
;       LCD_Send_Byte((DISPLAY_PAGE_SET + X), COMMAND, NORMAL); // Set page 
	clr R2
	std y+0,R2
	clr R18
	mov R16,R22
	subi R16,72    ; addi 184
	xcall _LCD_Send_Byte
	.dbline 309
;       LCD_Send_Byte((DISPLAY_COLUMN_SET + Y - 64), COMMAND, NORMAL); // Set column
	clr R2
	std y+0,R2
	clr R18
	mov R16,R20
	subi R16,192    ; addi 64
	subi R16,64
	xcall _LCD_Send_Byte
	.dbline 310
; 	  }
	xjmp L63
L62:
	.dbline 312
;    else
;       {
	.dbline 313
;       LCD_INSTR_PORT |=  LCD_CS1; // Select left side
	sbi 0x12,4
	.dbline 314
;       LCD_INSTR_PORT &= ~LCD_CS2;
	cbi 0x12,5
	.dbline 315
; 	  LCD_Send_Byte((DISPLAY_PAGE_SET + X), COMMAND, NORMAL); // Set page 
	clr R2
	std y+0,R2
	clr R18
	mov R16,R22
	subi R16,72    ; addi 184
	xcall _LCD_Send_Byte
	.dbline 316
;       LCD_Send_Byte((DISPLAY_COLUMN_SET + Y), COMMAND, NORMAL); // Set column
	clr R2
	std y+0,R2
	clr R18
	mov R16,R20
	subi R16,192    ; addi 64
	xcall _LCD_Send_Byte
	.dbline 317
; 	  }	  	  
L63:
	.dbline -2
L61:
	.dbline 0 ; func end
	adiw R28,1
	ld R22,y+
	ld R20,y+
	ret
	.dbsym r Y 20 c
	.dbsym r X 22 c
	.dbend
	.dbfunc s LCD_Disp_a_Char _LCD_Disp_a_Char fV
;             cl -> R20
;     Video_Mode -> y+11
;     Char_Value -> R22
;              Y -> R10
;              X -> R12
	.even
_LCD_Disp_a_Char:
	xcall push_xgsetF03C
	mov R10,R18
	mov R12,R16
	sbiw R28,1
	ldd R22,y+9
	.dbline -1
	.dbline 343
;    }
;   
; /*----------------------------------------------------------------------------*-
; 
;    LCD_Disp_a_Char()    
;  
;    Used to determine where we want to dispaly a char on the LCD panel 
;    and - thus - whether the text appears on Page 0, page 1, Column 0, 
;    Column 1, etc.
; 
;    Parameters:  
;    ---------------------------------------------------------------------------
;    X : range (Page 0 ~ Page 7)    
;    Y : range (0 ~ 127)
;    Params (X, Y) : The DDRAM address we wish to write to.
; 
;    Char_Value : The character value which's going to be displayed 
;                 on the LCD panel 
; 			   
;    Video_Mode : If Video_Mode == INVERSE(1), inverse video mode			   
;                 If Video_Mode == NORMAL(0), normal video mode
; 			   
; -*----------------------------------------------------------------------------*/
; static void LCD_Disp_a_Char(uInt8 X, uInt8 Y, uInt8 Char_Value, 
;                             uInt8 Video_Mode)
;    {
	.dbline 348
;    uInt8 cl;
;    
;    // Fine the char in the lookup table
;    // See "FONT6x8.C" for details
;    Char_Value -= 32;
	subi R22,32
	.dbline 350
;      
;    for (cl = 0; cl < 6; cl++)
	clr R20
	xjmp L68
L65:
	.dbline 351
;       {
	.dbline 352
; 	  LCD_Set_XY(X, Y + cl);
	mov R18,R10
	add R18,R20
	mov R16,R12
	xcall _LCD_Set_XY
	.dbline 353
;       LCD_Send_Byte(FONT6x8[Char_Value][cl], D_DATA, Video_Mode);
	ldd R0,y+11
	std y+0,R0
	ldi R18,1
	ldi R24,6
	mul R24,R22
	movw R2,R0
	ldi R24,<_FONT6x8
	ldi R25,>_FONT6x8
	add R2,R24
	adc R3,R25
	mov R30,R20
	clr R31
	add R30,R2
	adc R31,R3
	lpm R16,Z
	xcall _LCD_Send_Byte
	.dbline 354
; 	  }
L66:
	.dbline 350
	inc R20
L68:
	.dbline 350
	cpi R20,6
	brlo L65
X18:
	.dbline -2
L64:
	.dbline 0 ; func end
	adiw R28,1

⌨️ 快捷键说明

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