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

📄 ks0108_12864lcd_m16.lst

📁 ks0108 avr单片机1284显示
💻 LST
📖 第 1 页 / 共 4 页
字号:
     581 0000      NOP
     582 9BCF      SBIS	0x19,7
     583 C006      RJMP	0x058A
     584 01C8      MOVW	R24,R16
     585 9601      ADIW	R24,1
     586 018C      MOVW	R16,R24
     587 3080      CPI	R24,0
     588 0789      CPC	R24,R25
     589 F791      BNE	0x057C
(0241)       }
(0242)    LCD_DATA_PORT_DIR = OUTPUT; // Set data PORT direction back to an output
     58A EF8F      LDI	R24,0xFF
     58B BB8A      OUT	0x1A,R24
(0243)    LCD_INSTR_PORT &= ~LCD_EN;
     58C 9892      CBI	0x12,2
     58D 9508      RET
(0244)    }     
(0245)    
(0246) /*----------------------------------------------------------------------------*-
(0247) 
(0248)    LCD_Send_Byte()
(0249) 
(0250)    This function writes a byte to the LCD panel.
(0251) 
(0252)    Parameters: 
(0253)    ---------------------------------------------------------------------------
(0254)    Data      : The byte to be written to the LCD
(0255)     
(0256)    DATA_FLAG : If DATA_FLAG == 1, a data byte is sent
(0257)                If DATA_FLAG == 0, a command byte is sent
(0258) 			  
(0259)    IVERSE    : If IVERSE == 1, inverse video mode			   
(0260)                If IVERSE == 0, normal video mode
(0261) 			  
(0262) -*----------------------------------------------------------------------------*/
(0263) static void LCD_Send_Byte(uInt8 DATA, uInt8 DATA_FLAG, uInt8 IVERSE)
(0264)    { 
(0265)    // LCD_Read_Busy();
(0266)      
(0267)    LCD_INSTR_PORT |=  LCD_EN;
KS0108_12864LCD.C:LCD_Send_Byte:
_LCD_Send_Byte:
  IVERSE               --> Y,+0
  DATA_FLAG            --> R18
  DATA                 --> R16
     58E 9A92      SBI	0x12,2
(0268)    asm("nop");	
     58F 0000      NOP
(0269)    asm("nop");
     590 0000      NOP
(0270)    
(0271)    if (DATA_FLAG)
     591 2322      TST	R18
     592 F011      BEQ	0x0595
(0272)       LCD_INSTR_PORT |=  LCD_DI; // Set data   
     593 9A90      SBI	0x12,0
     594 C001      RJMP	0x0596
(0273)    else
(0274)       LCD_INSTR_PORT &= ~LCD_DI; // Set instruction
     595 9890      CBI	0x12,0
(0275) 
(0276)    LCD_INSTR_PORT &= ~LCD_RW; // Set write
     596 9891      CBI	0x12,1
(0277)    
(0278)    if (IVERSE && DATA_FLAG)   
     597 8008      LDD	R0,Y+0
     598 2000      TST	R0
     599 F051      BEQ	0x05A4
     59A 2322      TST	R18
     59B F041      BEQ	0x05A4
(0279)       LCD_DATA_PORT = 255 - DATA; // Send inverse data
     59C 2E20      MOV	R2,R16
     59D 2433      CLR	R3
     59E EF8F      LDI	R24,0xFF
     59F E090      LDI	R25,0
     5A0 1982      SUB	R24,R2
     5A1 0993      SBC	R25,R3
     5A2 BB8B      OUT	0x1B,R24
     5A3 C001      RJMP	0x05A5
(0280)    else
(0281)       LCD_DATA_PORT = DATA; // Send data or instruction
     5A4 BB0B      OUT	0x1B,R16
(0282)    
(0283)    LCD_INSTR_PORT &= ~LCD_EN; // Toggle enable
     5A5 9892      CBI	0x12,2
(0284)    asm("nop");	
     5A6 0000      NOP
(0285)    asm("nop");
     5A7 0000      NOP
     5A8 9508      RET
_LCD_Set_XY:
  Y                    --> R20
  X                    --> R22
KS0108_12864LCD.C:LCD_Set_XY:
     5A9 934A      ST	R20,-Y
     5AA 936A      ST	R22,-Y
     5AB 2F42      MOV	R20,R18
     5AC 2F60      MOV	R22,R16
     5AD 9721      SBIW	R28,1
(0286)    }
(0287) 
(0288) /*----------------------------------------------------------------------------*-
(0289)   
(0290)    LCD_Set_XY()
(0291) 
(0292)    Set the DDRAM to a particular address.
(0293) 
(0294)    Used to determine where we write to in the LCD RAM and - thus -
(0295)    whether the text appears on Page 0, page 1, Column 0, Column 1, etc.
(0296) 
(0297)    Params (X, Y) : The DDRAM address we wish to write to. 
(0298)    
(0299)    X range : (Page 0 ~ Page 7), Y range : (0 ~ 127)
(0300) 
(0301) -*----------------------------------------------------------------------------*/
(0302) static void LCD_Set_XY(uInt8 X, uInt8 Y)
(0303)    {
(0304)    if (Y >= 64)
     5AE 3440      CPI	R20,0x40
     5AF F080      BCS	0x05C0
(0305)       {
(0306)       LCD_INSTR_PORT &= ~LCD_CS1; // Select right side
     5B0 9894      CBI	0x12,4
(0307)       LCD_INSTR_PORT |=  LCD_CS2;
     5B1 9A95      SBI	0x12,5
(0308)       LCD_Send_Byte((DISPLAY_PAGE_SET + X), COMMAND, NORMAL); // Set page 
     5B2 2422      CLR	R2
     5B3 8228      STD	Y+0,R2
     5B4 2722      CLR	R18
     5B5 2F06      MOV	R16,R22
     5B6 5408      SUBI	R16,0x48
     5B7 DFD6      RCALL	KS0108_12864LCD.C:LCD_Send_Byte
(0309)       LCD_Send_Byte((DISPLAY_COLUMN_SET + Y - 64), COMMAND, NORMAL); // Set column
     5B8 2422      CLR	R2
     5B9 8228      STD	Y+0,R2
     5BA 2722      CLR	R18
     5BB 2F04      MOV	R16,R20
     5BC 5C00      SUBI	R16,0xC0
     5BD 5400      SUBI	R16,0x40
     5BE DFCF      RCALL	KS0108_12864LCD.C:LCD_Send_Byte
(0310) 	  }
     5BF C00E      RJMP	0x05CE
(0311)    else
(0312)       {
(0313)       LCD_INSTR_PORT |=  LCD_CS1; // Select left side
     5C0 9A94      SBI	0x12,4
(0314)       LCD_INSTR_PORT &= ~LCD_CS2;
     5C1 9895      CBI	0x12,5
(0315) 	  LCD_Send_Byte((DISPLAY_PAGE_SET + X), COMMAND, NORMAL); // Set page 
     5C2 2422      CLR	R2
     5C3 8228      STD	Y+0,R2
     5C4 2722      CLR	R18
     5C5 2F06      MOV	R16,R22
     5C6 5408      SUBI	R16,0x48
     5C7 DFC6      RCALL	KS0108_12864LCD.C:LCD_Send_Byte
(0316)       LCD_Send_Byte((DISPLAY_COLUMN_SET + Y), COMMAND, NORMAL); // Set column
     5C8 2422      CLR	R2
     5C9 8228      STD	Y+0,R2
     5CA 2722      CLR	R18
     5CB 2F04      MOV	R16,R20
     5CC 5C00      SUBI	R16,0xC0
     5CD DFC0      RCALL	KS0108_12864LCD.C:LCD_Send_Byte
(0317) 	  }	  	  
     5CE 9621      ADIW	R28,1
     5CF 9169      LD	R22,Y+
     5D0 9149      LD	R20,Y+
     5D1 9508      RET
_LCD_Disp_a_Char:
  cl                   --> R20
  Video_Mode           --> Y,+11
  Char_Value           --> R22
  Y                    --> R10
  X                    --> R12
KS0108_12864LCD.C:LCD_Disp_a_Char:
     5D2 940E 0712 CALL	push_xgsetF03C
     5D4 2EA2      MOV	R10,R18
     5D5 2EC0      MOV	R12,R16
     5D6 9721      SBIW	R28,1
     5D7 8569      LDD	R22,Y+9
(0318)    }
(0319)   
(0320) /*----------------------------------------------------------------------------*-
(0321) 
(0322)    LCD_Disp_a_Char()    
(0323)  
(0324)    Used to determine where we want to dispaly a char on the LCD panel 
(0325)    and - thus - whether the text appears on Page 0, page 1, Column 0, 
(0326)    Column 1, etc.
(0327) 
(0328)    Parameters:  
(0329)    ---------------------------------------------------------------------------
(0330)    X : range (Page 0 ~ Page 7)    
(0331)    Y : range (0 ~ 127)
(0332)    Params (X, Y) : The DDRAM address we wish to write to.
(0333) 
(0334)    Char_Value : The character value which's going to be displayed 
(0335)                 on the LCD panel 
(0336) 			   
(0337)    Video_Mode : If Video_Mode == INVERSE(1), inverse video mode			   
(0338)                 If Video_Mode == NORMAL(0), normal video mode
(0339) 			   
(0340) -*----------------------------------------------------------------------------*/
(0341) static void LCD_Disp_a_Char(uInt8 X, uInt8 Y, uInt8 Char_Value, 
(0342)                             uInt8 Video_Mode)
(0343)    {
(0344)    uInt8 cl;
(0345)    
(0346)    // Fine the char in the lookup table
(0347)    // See "FONT6x8.C" for details
(0348)    Char_Value -= 32;
     5D8 5260      SUBI	R22,0x20
(0349)      
(0350)    for (cl = 0; cl < 6; cl++)
     5D9 2744      CLR	R20
     5DA C015      RJMP	0x05F0
(0351)       {
(0352) 	  LCD_Set_XY(X, Y + cl);
     5DB 2D2A      MOV	R18,R10
     5DC 0F24      ADD	R18,R20
     5DD 2D0C      MOV	R16,R12
     5DE DFCA      RCALL	_LCD_Set_XY
(0353)       LCD_Send_Byte(FONT6x8[Char_Value][cl], D_DATA, Video_Mode);
     5DF 840B      LDD	R0,Y+11
     5E0 8208      STD	Y+0,R0
     5E1 E021      LDI	R18,1
     5E2 E086      LDI	R24,6
     5E3 9F86      MUL	R24,R22
     5E4 0110      MOVW	R2,R0
     5E5 E880      LDI	R24,0x80
     5E6 E090      LDI	R25,0
     5E7 0E28      ADD	R2,R24
     5E8 1E39      ADC	R3,R25
     5E9 2FE4      MOV	R30,R20
     5EA 27FF      CLR	R31
     5EB 0DE2      ADD	R30,R2
     5EC 1DF3      ADC	R31,R3
     5ED 9104      LPM	R16,0(Z)
     5EE DF9F      RCALL	KS0108_12864LCD.C:LCD_Send_Byte
     5EF 9543      INC	R20
     5F0 3046      CPI	R20,6
     5F1 F348      BCS	0x05DB
     5F2 9621      ADIW	R28,1
     5F3 940C 071B JMP	pop_xgsetF03C
KS0108_12864LCD.C:LCD_Disp_String:
_LCD_Disp_String:
  Video_Mode           --> Y,+11
  pString              --> R20
  Y                    --> R22
  X                    --> R10
     5F5 940E 0704 CALL	push_xgsetF00C
     5F7 2F62      MOV	R22,R18
     5F8 2EA0      MOV	R10,R16
     5F9 9723      SBIW	R28,3
     5FA 8549      LDD	R20,Y+9
     5FB 855A      LDD	R21,Y+10
(0354) 	  }
(0355)    }
(0356) 
(0357) /*----------------------------------------------------------------------------*-
(0358)    
(0359)    LCD_Disp_String()
(0360) 
(0361)    Used to determine where we want to dispaly a string on the LCD panel 
(0362)    and - thus - whether the text appears on Page 0, page 1, Column 0, 
(0363)    Column 1, etc.
(0364) 
(0365)    Parameters: 
(0366)    ---------------------------------------------------------------------------
(0367)    X : range (Page 0 ~ Page 7)    
(0368)    Y : range (0 ~ 127)
(0369)    Params (X, Y) : The DDRAM address we wish to write to.
(0370) 
(0371)    pString    : The string pointer point out the string which's going to 
(0372)                 be displayed on the LCD panel
(0373) 
(0374)    Video_Mode : If Video_Mode == INVERSE(1), inverse video mode			   
(0375)                 If Video_Mode == NORMAL(0), normal video mode
(0376) 				   		
(0377) -*----------------------------------------------------------------------------*/
(0378) static void LCD_Disp_String(uInt8 X, uInt8 Y, flash uInt8 * pString, 
(0379)                             uInt8 Video_Mode)
(0380)    {
     5FC C00B      RJMP	0x0608
(0381)    while (* pString) 
(0382)       {
(0383)       LCD_Disp_a_Char(X, Y, * pString, Video_Mode);
     5FD 840B      LDD	R0,Y+11
     5FE 820A      STD	Y+2,R0
     5FF 01FA      MOVW	R30,R20
     600 9024      LPM	R2,2(Z)
     601 8228      STD	Y+0,R2
     602 2F26      MOV	R18,R22
     603 2D0A      MOV	R16,R10
     604 DFCD      RCALL	_LCD_Disp_a_Char
(0384) 	  Y += 6; // Characters are 6x8 pixel
     605 5F6A      SUBI	R22,0xFA
(0385) 	  pString++;	  
     606 5F4F      SUBI	R20,0xFF
     607 4F5F      SBCI	R21,0xFF
     608 01FA      MOVW	R30,R20
     609 9024      LPM	R2,255(Z)
     60A 2022      TST	R2
     60B F789      BNE	0x05FD
     60C 9623      ADIW	R28,3
     60D 940C 070B JMP	pop_xgsetF00C
_LCD_Disp_Chinese_String:
  nm                   --> R10
  cl                   --> R22
  Video_Mode           --> Y,+21
  pCN_String           --> Y,+19
  Char_Gap             --> Y,+17
  Start_Char           --> Y,+15
  Char_Amount          --> Y,+13
  Char_Length          --> R12
  Y                    --> R14
  X                    --> R20
KS0108_12864LCD.C:LCD_Disp_Chinese_String:
     60F 940E 06EF CALL	push_xgsetF0FC
     611 2EE2      MOV	R14,R18
     612 2F40      MOV	R20,R16
     613 9721      SBIW	R28,1
     614 84CB      LDD	R12,Y+11
(0386)       }
(0387)    }   
(0388) 
(0389) /*----------------------------------------------------------------------------*-
(0390) 
(0391)    LCD_Disp_Chinese_String()
(0392)   
(0393)    Display a Chinese String on the LCD panel.
(0394)   
(0395)    Parameters: 
(0396)    ---------------------------------------------------------------------------
(0397)    X, Y        : The Chinese String start coordinates on the LCD panel
(0398)     
(0399)    Char_Length : The Chinese character's length (in pixel)
(0400)    Char_Amount : The amount of Chinese characters 
(0401)    Start_Char  : Which Chinese character should be display first in the array
(0402)    Char_Gap    : The space between on characters to another (in pixel)
(0403)    
(0404)    Video_Mode  : If Video_Mode == INVERSE(1), inverse video mode			   
(0405)                  If Video_Mode == NORMAL(0), normal video mode
(0406) 	
(0407) -*----------------------------------------------------------------------------*/                        
(0408) static void LCD_Disp_Chinese_String (uInt8 X, uInt8 Y, 
(0409)                                      uInt8 Char_Length, uInt8 Char_Amount,
(0410)                                      uInt8 Start_Char, uInt8 Char_Gap,
(0411) 									 flash uInt8 (* pCN_String)[32], 
(0412) 									 uInt8 Video_Mode)
(0413)    {
(0414)    uInt8 cl, nm; 
(0415)     
(0416)    for (nm = 0; nm < Char_Amount; )
     615 24AA      CLR	R10
     616 C02F      RJMP	0x0646
(0417)       {
(0418)       for (cl = 0; cl < Char_Length * 2; cl++) // Send a Chinese character
     617 2766      CLR	R22
     618 C023      RJMP	0x063C
(0419)          { 
(0420)       	 if (cl >= Char_Length)  
     619 156C      CP	R22,R12
     61A F038      BCS	0x0622
(0421)             { 
(0422) 			// Send below part of a Chinese character
(0423) 			LCD_Set_XY(X + 1, Y + cl - Char_Length);
     61B 2D2E      MOV	R18,R14
     61C 0F26      ADD	R18,R22
     61D 192C      SUB	R18,R12
     61E 2F04      MOV	R16,R20
     61F 5F0F      SUBI	R16,0xFF
     620 DF88      RCALL	_LCD_Set_XY
(0424) 			}
     621 C004      RJMP	0x0626
(0425)          else
(0426) 		    {
(0427) 		    // Set coordinates    
(0428)             LCD_Set_XY(X, Y + cl);
     622 2D2E      MOV	R18,R14
     623 0F26      ADD	R18,R22
     624 2F04      MOV	R16,R20
     625 DF83      RCALL	_LCD_Set_XY
(0429) 			}
(0430)  
(0431)       	 LCD_Send_Byte(* (* (pCN_String + Start_Char + nm)+ cl), 
     626 880D      LDD	R0,Y+21
     627 8208      STD	Y+0,R0
     628 E021      LDI	R18,1
     629 E280      LDI	R24,0x20
     62A 840F      LDD	R0,Y+15

⌨️ 快捷键说明

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