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

📄 project.lst

📁 AVR单片机C语言程序设计实例精粹
💻 LST
📖 第 1 页 / 共 5 页
字号:
(0054) // Description : Low Level Interface Function
(0055) //******************************************************************************
(0056) void Set_RW(INT8U RW)
(0057) {
(0058) 	if(RW == 0)
_Set_RW:
  RW                   --> R16
    0781 2300      TST	R16
    0782 F411      BNE	0x0785
(0059) 	{
(0060) 		PORTB &= ~0x02;
    0783 98C1      CBI	0x18,1
(0061) 	}
    0784 C001      RJMP	0x0786
(0062) 	else
(0063) 	{
(0064) 		PORTB |= 0x02;
    0785 9AC1      SBI	0x18,1
(0065) 	}
(0066) }
    0786 9508      RET
(0067) 
(0068) //******************************************************************************
(0069) // Function    : Set_EN
(0070) // Input       : RW - RW Control Line Level
(0071) // Output      : none
(0072) // Description : Low Level Interface Function
(0073) //******************************************************************************
(0074) void Set_EN(INT8U EN)
(0075) {
(0076) 	if(EN == 0)
_Set_EN:
  EN                   --> R16
    0787 2300      TST	R16
    0788 F411      BNE	0x078B
(0077) 	{
(0078) 		PORTB &= ~0x04;
    0789 98C2      CBI	0x18,2
(0079) 	}
    078A C001      RJMP	0x078C
(0080) 	else
(0081) 	{
(0082) 		PORTB |= 0x04;
    078B 9AC2      SBI	0x18,2
(0083) 	}
(0084) }
    078C 9508      RET
(0085) 
(0086) //******************************************************************************
(0087) // Function    : Set_CS2
(0088) // Input       : CS2 - CS2 Control Line Level
(0089) // Output      : none
(0090) // Description : Low Level Interface Function
(0091) //******************************************************************************
(0092) void Set_CS2(INT8U CS2)
(0093) {
(0094) 	if(CS2 == 0) 
_Set_CS2:
  CS2                  --> R16
    078D 2300      TST	R16
    078E F411      BNE	0x0791
(0095) 	{
(0096) 		PORTC &= ~0x20;
    078F 98AD      CBI	0x15,5
(0097) 	}
    0790 C001      RJMP	0x0792
(0098)  	else
(0099)  	{
(0100)  		PORTC |= 0x20;
    0791 9AAD      SBI	0x15,5
(0101)  	}
(0102) }
    0792 9508      RET
(0103) 
(0104) //******************************************************************************
(0105) // Function    : Set_CS1
(0106) // Input       : CS1 - CS1 Control Line Level
(0107) // Output      : none
(0108) // Description : Low Level Interface Function
(0109) //******************************************************************************
(0110) void Set_CS1(INT8U CS1)
(0111) {
(0112) 	if(CS1 == 0)
_Set_CS1:
  CS1                  --> R16
    0793 2300      TST	R16
    0794 F411      BNE	0x0797
(0113) 	{
(0114) 		PORTC &= ~0x40;
    0795 98AE      CBI	0x15,6
(0115) 	}
    0796 C001      RJMP	0x0798
(0116) 	else
(0117) 	{
(0118) 		PORTC |= 0x40;
    0797 9AAE      SBI	0x15,6
(0119) 	}
(0120) }
    0798 9508      RET
(0121) 
(0122) 
(0123) //******************************************************************************
(0124) // Function    : Set_CS1
(0125) // Input       : CS1 - CS1 Control Line Level
(0126) // Output      : none
(0127) // Description : Low Level Interface Function
(0128) //******************************************************************************
(0129) void Set_RST(INT8U RST)
(0130) {
(0131) 	if(RST == 0)
_Set_RST:
  RST                  --> R16
    0799 2300      TST	R16
    079A F411      BNE	0x079D
(0132) 	{
(0133) 		PORTC &= ~0x80;
    079B 98AF      CBI	0x15,7
(0134) 	}
    079C C001      RJMP	0x079E
(0135) 	else
(0136) 	{
(0137) 		PORTC |= 0x80;
    079D 9AAF      SBI	0x15,7
(0138) 	}
(0139) }
    079E 9508      RET
(0140)  
(0141) //******************************************************************************
(0142) // Function    : Set_Data
(0143) // Input       : data - Data Line Level
(0144) // Output      : none
(0145) // Description : Low Level Interface Function
(0146) //******************************************************************************
(0147) void Set_Data(INT8U data)
(0148) {
(0149) 	PORTA  = data;
_Set_Data:
  data                 --> R16
    079F BB0B      OUT	0x1B,R16
(0150) }
    07A0 9508      RET
_LCD_Command_DispOnOff:
  onoff                --> R20
    07A1 940E0E49  CALL	push_gset1
    07A3 2F40      MOV	R20,R16
(0151) 
(0152) //******************************************************************************
(0153) // Function    : LCD_Command_DispOnOff
(0154) // Input       : onoff = 1 -> LCD Display Enabled,else Disabled
(0155) // Output      : none
(0156) // Description : Command Level Function,Display ONOFF Control
(0157) //******************************************************************************
(0158) void LCD_Command_DispOnOff(INT8U onoff)
(0159) {
(0160) 	Set_RW(0);
    07A4 2700      CLR	R16
    07A5 DFDB      RCALL	_Set_RW
(0161) 	Set_DI(0);
    07A6 2700      CLR	R16
    07A7 DFD3      RCALL	_Set_DI
(0162) 	Set_EN(0);
    07A8 2700      CLR	R16
    07A9 DFDD      RCALL	_Set_EN
(0163) 	Set_Data(0x3E + onoff);
    07AA 2F04      MOV	R16,R20
    07AB 5C02      SUBI	R16,0xC2
    07AC DFF2      RCALL	_Set_Data
(0164) 	Set_EN(1);
    07AD E001      LDI	R16,1
    07AE DFD8      RCALL	_Set_EN
(0165) 	Set_EN(0);
    07AF 2700      CLR	R16
    07B0 DFD6      RCALL	_Set_EN
(0166) }
    07B1 940E0E4C  CALL	pop_gset1
    07B3 9508      RET
_LCD_Command_SetStartLine:
  startline            --> R20
    07B4 940E0E49  CALL	push_gset1
    07B6 2F40      MOV	R20,R16
(0167) 
(0168) //******************************************************************************
(0169) // Function    : LCD_Command_SetStartLine
(0170) // Input       : startline - Display Start Line,See Specification
(0171) // Output      : none
(0172) // Description : Command Level Function,Set Display Start Line
(0173) //******************************************************************************
(0174) void LCD_Command_SetStartLine(INT8U startline)
(0175) {
(0176) 	Set_RW(0);
    07B7 2700      CLR	R16
    07B8 DFC8      RCALL	_Set_RW
(0177) 	Set_DI(0);																
    07B9 2700      CLR	R16
    07BA DFC0      RCALL	_Set_DI
(0178) 	Set_EN(0);																
    07BB 2700      CLR	R16
    07BC DFCA      RCALL	_Set_EN
(0179) 	Set_Data(0xC0 + startline);
    07BD 2F04      MOV	R16,R20
    07BE 5400      SUBI	R16,0x40
    07BF DFDF      RCALL	_Set_Data
(0180) 	Set_EN(1);																
    07C0 E001      LDI	R16,1
    07C1 DFC5      RCALL	_Set_EN
(0181) 	Set_EN(0);																
    07C2 2700      CLR	R16
    07C3 DFC3      RCALL	_Set_EN
(0182) }
    07C4 940E0E4C  CALL	pop_gset1
    07C6 9508      RET
_LCD_Command_Set_X:
  x                    --> R20
    07C7 940E0E49  CALL	push_gset1
    07C9 2F40      MOV	R20,R16
(0183) 
(0184) //******************************************************************************
(0185) // Function    : LCD_Command_Set_X
(0186) // Input       : x - Display Row,from 0 to 7 for 128*64 LCD
(0187) // Output      : none
(0188) // Description : Command Level Function,Set Operation X Address
(0189) //******************************************************************************
(0190) void LCD_Command_Set_X(INT8U x)
(0191) {
(0192) 	Set_RW(0);
    07CA 2700      CLR	R16
    07CB DFB5      RCALL	_Set_RW
(0193) 	Set_DI(0);
    07CC 2700      CLR	R16
    07CD DFAD      RCALL	_Set_DI
(0194) 	Set_EN(0);
    07CE 2700      CLR	R16
    07CF DFB7      RCALL	_Set_EN
(0195) 	Set_Data(0xB8 + x);
    07D0 2F04      MOV	R16,R20
    07D1 5408      SUBI	R16,0x48
    07D2 DFCC      RCALL	_Set_Data
(0196) 	Set_EN(1);
    07D3 E001      LDI	R16,1
    07D4 DFB2      RCALL	_Set_EN
(0197) 	Set_EN(0);
    07D5 2700      CLR	R16
    07D6 DFB0      RCALL	_Set_EN
(0198) }
    07D7 940E0E4C  CALL	pop_gset1
    07D9 9508      RET
_LCD_Command_Set_Y:
  column               --> R20
    07DA 940E0E49  CALL	push_gset1
    07DC 2F40      MOV	R20,R16
(0199) 
(0200) //******************************************************************************
(0201) // Function    : LCD_Command_Set_Y
(0202) // Input       : y - Display Column,from 0 to 63 for 128*64 LCD
(0203) // Output      : none
(0204) // Description : Command Level Function,Set Operation Y Address
(0205) //******************************************************************************
(0206) void LCD_Command_Set_Y(INT8U column)
(0207) {
(0208) 	Set_RW(0);
    07DD 2700      CLR	R16
    07DE DFA2      RCALL	_Set_RW
(0209) 	Set_DI(0);
    07DF 2700      CLR	R16
    07E0 DF9A      RCALL	_Set_DI
(0210) 	Set_EN(0);
    07E1 2700      CLR	R16
    07E2 DFA4      RCALL	_Set_EN
(0211) 	Set_Data(0x40 + column);
    07E3 2F04      MOV	R16,R20
    07E4 5C00      SUBI	R16,0xC0
    07E5 DFB9      RCALL	_Set_Data
(0212) 	Set_EN(1);
    07E6 E001      LDI	R16,1
    07E7 DF9F      RCALL	_Set_EN
(0213) 	Set_EN(0);
    07E8 2700      CLR	R16
    07E9 DF9D      RCALL	_Set_EN
(0214) }
    07EA 940E0E4C  CALL	pop_gset1
    07EC 9508      RET
_LCD_Command_WriteByte:
  data                 --> R20
    07ED 940E0E49  CALL	push_gset1
    07EF 2F40      MOV	R20,R16
(0215) 
(0216) //******************************************************************************
(0217) // Function    : LCD_Command_WriteByte
(0218) // Input       : data - Display Data
(0219) // Output      : none
(0220) // Description : Command Level Function,Write Display Data to DDRAM
(0221) //******************************************************************************
(0222) void LCD_Command_WriteByte(INT8U data)
(0223) {
(0224) 	Set_RW(0);
    07F0 2700      CLR	R16
    07F1 DF8F      RCALL	_Set_RW
(0225) 	Set_DI(1);
    07F2 E001      LDI	R16,1
    07F3 DF87      RCALL	_Set_DI
(0226) 	Set_EN(0);
    07F4 2700      CLR	R16
    07F5 DF91      RCALL	_Set_EN
(0227) 	Set_Data(data);
    07F6 2F04      MOV	R16,R20
    07F7 DFA7      RCALL	_Set_Data
(0228) 	Set_EN(1);
    07F8 E001      LDI	R16,1
    07F9 DF8D      RCALL	_Set_EN
(0229) 	Set_EN(0);
    07FA 2700      CLR	R16
    07FB DF8B      RCALL	_Set_EN
(0230) }
    07FC 940E0E4C  CALL	pop_gset1
    07FE 9508      RET
(0231) 
(0232) //******************************************************************************
(0233) // Function    : LCD_Reset
(0234) // Input       : none
(0235) // Output      : none
(0236) // Description : Command Level Function,Soft RESET LCD Module
(0237) //******************************************************************************
(0238) void LCD_Reset(void)
(0239) {
(0240) 	Set_RST(0);
_LCD_Reset:
    07FF 2700      CLR	R16
    0800 DF98      RCALL	_Set_RST
(0241) 	Set_RST(1);
    0801 E001      LDI	R16,1
(0242) }
    0802 CF96      RJMP	_Set_RST
(0243) 
(0244) //******************************************************************************
(0245) // Function    : LCD_Init
(0246) // Input       : none
(0247) // Output      : none
(0248) // Description : Application Level Function,Init LCD
(0249) //******************************************************************************
(0250) void LCD_Init(void)
(0251) {
(0252) 	LCD_Reset();
_LCD_Init:
    0803 DFFB      RCALL	_LCD_Reset
(0253) 	LCD_Clear_Line(0,7);
    0804 E027      LDI	R18,7
    0805 2700      CLR	R16
    0806 D004      RCALL	_LCD_Clear_Line
(0254) 	LCD_Command_DispOnOff(1);
    0807 E001      LDI	R16,1
    0808 DF98      RCALL	_LCD_Command_DispOnOff
(0255) 	LCD_Command_SetStartLine(0);
    0809 2700      CLR	R16
(0256) }
    080A CFA9      RJMP	_LCD_Command_SetStartLine
_LCD_Clear_Line:
  i                    --> R20
  j                    --> R10
  endline              --> R22
  startline            --> R10
    080B 940E0E64  CALL	push_gset3
    080D 2F62      MOV	R22,R18
    080E 2EA0      MOV	R10,R16
(0257) 
(0258) //******************************************************************************
(0259) // Function    : LCD_Clear_Line
(0260) // Input       : startline,endline - Line Range to be Cleare
(0261) // Output      : none
(0262) // Description : Command Level Function,Clear Screen Display
(0263) //******************************************************************************
(0264) void LCD_Clear_Line(INT8U startline,INT8U endline)
(0265) {
(0266) 	INT8U i,j;
(0267) 	for(i = startline;i <= endline;i++)
    080F 2D4A      MOV	R20,R10
    0810 C011      RJMP	0x0822
(0268) 	{
(0269) 		Set_CS1(1);
    0811 E001      LDI	R16,1
    0812 DF80      RCALL	_Set_CS1
(0270) 		Set_CS2(1);
    0813 E001      LDI	R16,1
    0814 DF78      RCALL	_Set_CS2
(0271) 		LCD_Command_Set_X(i);
    0815 2F04      MOV	R16,R20
    0816 DFB0      RCALL	_LCD_Command_Set_X
(0272) 		LCD_Command_Set_Y(0);
    0817 2700      CLR	R16
    0818 DFC1      RCALL	_LCD_Command_Set_Y
(0273) 		for(j = 0;j < 64;j++)
    0819 24AA      CLR	R10
    081A C003      RJMP	0x081E
(0274) 		{
(0275) 			LCD_Command_WriteByte(0x00);
    081B 2700      CLR	R16
    081C DFD0      RCALL	_LCD_Command_WriteByte
    081D 94A3      INC	R10
    081E 2D8A      MOV	R24,R10
    081F 3480      CPI	R24,0x40
    0820 F3D0      BCS	0x081B
    0821 9543      INC	R20
    0822 1764      CP	R22,R20
    0823 F768      BCC	0x0811
(0276) 		}
(0277) 	}
(0278) }

⌨️ 快捷键说明

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