📄 lcd.lis
字号:
.module LCD.c
.area text(rom, con, rel)
0000 .dbfile cfile\LCD.c
0000 .dbfile F:\file\数控电源3\ad_da\cfile\LCD.c
0000 .dbfunc e LCD_INIT _LCD_INIT fV
.even
0000 _LCD_INIT::
0000 .dbline -1
0000 .dbline 52
0000 ; // ************************************************
0000 ; // *** 采用4位数据线的1602液晶驱动程序 ***
0000 ; // *** LCD.C ***
0000 ; // ************************************************
0000 ; #define ENABLE_BIT_DEFINITIONS
0000 ; #define LCD_C
0000 ; #include "includes.h"
0000 ; // ***** Define I/O pins ***** //
0000 ; #define BIT7 0x80
0000 ; #define BIT6 0x40
0000 ; #define BIT5 0x20
0000 ; #define BIT4 0x10
0000 ; #define BIT3 0x08
0000 ; #define BIT2 0x04
0000 ; #define BIT1 0x02
0000 ; #define BIT0 0x01
0000 ; // *** Set port for LCD Data Bus 8 bit mode *** //
0000 ; #define LCD_OP_PORT PORTB
0000 ; #define LCD_IP_PORT PINB
0000 ; #define LCD_DIR_PORT DDRB
0000 ; // *** Set LCD Enable Port and Bit values *** //
0000 ; //#define LCD_EN LCD_OP_PORT.2
0000 ; // *** Set LCD Register Select Port and Bit values *** //
0000 ; //#define LCD_RS LCD_OP_PORT.0
0000 ; // *** Set LCD Read/Write Port and Bit values *** //
0000 ; //#define LCD_RW LCD_OP_PORT.1
0000 ; /****************************************************************/
0000 ;
0000 ; #define LCD_EN (1 << 2) //引脚定义
0000 ; #define LCD_RS (1 << 0)
0000 ; #define LCD_RW (1 << 1)
0000 ;
0000 ; #define lcd_set_e() (LCD_OP_PORT |= LCD_EN) //置位与清零
0000 ; #define lcd_set_rs() (LCD_OP_PORT |= LCD_RS)
0000 ; #define lcd_set_rw() (LCD_OP_PORT |= LCD_RW)
0000 ; #define lcd_clear_e() (LCD_OP_PORT &= ~LCD_EN)
0000 ; #define lcd_clear_rs() (LCD_OP_PORT &= ~LCD_RS)
0000 ; #define lcd_clear_rw() (LCD_OP_PORT &= ~LCD_RW)
0000 ; /****************************************************************/
0000 ;
0000 ; #define LCD_ON 0x0C
0000 ; #define LCD_CURS_ON 0x0D
0000 ; #define LCD_OFF 0x08
0000 ; #define LCD_HOME 0x02
0000 ; #define LCD_CLEAR 0x01
0000 ; #define LCD_NEW_LINE 0xC0
0000 ; #define LCD_FUNCTION_SET 0x28
0000 ; #define LCD_MODE_SET 0x06
0000 ;
0000 ;
0000 ; void LCD_INIT(void)
0000 ; {
0000 .dbline 53
0000 ; LCD_DIR_PORT = 0xff; // LCD port output
0000 8FEF ldi R24,255
0002 87BB out 0x17,R24
0004 .dbline 54
0004 ; LCD_OP_PORT = 0x30; // Load high-data to port
0004 80E3 ldi R24,48
0006 88BB out 0x18,R24
0008 .dbline 55
0008 ; lcd_clear_rw(); // Set LCD to write
0008 C198 cbi 0x18,1
000A .dbline 56
000A ; lcd_clear_rs(); // Set LCD to command
000A C098 cbi 0x18,0
000C .dbline 57
000C ; lcd_set_e(); // Write data to LCD
000C C29A sbi 0x18,2
000E .dbline 58
000E ; asm("nop");
000E 0000 nop
0010 .dbline 59
0010 ; asm("nop");
0010 0000 nop
0012 .dbline 60
0012 ; lcd_clear_e(); // Disable LCD
0012 C298 cbi 0x18,2
0014 .dbline 61
0014 ; delay_nus(40);
0014 08E2 ldi R16,40
0016 10E0 ldi R17,0
0018 0E940000 xcall _delay_nus
001C .dbline 62
001C ; lcd_clear_rw() ; // Set LCD to write
001C C198 cbi 0x18,1
001E .dbline 63
001E ; lcd_clear_rs(); // Set LCD to command
001E C098 cbi 0x18,0
0020 .dbline 64
0020 ; lcd_set_e(); // Write data to LCD
0020 C29A sbi 0x18,2
0022 .dbline 65
0022 ; asm("nop");
0022 0000 nop
0024 .dbline 66
0024 ; asm("nop");
0024 0000 nop
0026 .dbline 67
0026 ; lcd_clear_e(); // Disable LCD
0026 C298 cbi 0x18,2
0028 .dbline 68
0028 ; delay_nus(40);
0028 08E2 ldi R16,40
002A 10E0 ldi R17,0
002C 0E940000 xcall _delay_nus
0030 .dbline 69
0030 ; lcd_set_e(); // Write data to LCD
0030 C29A sbi 0x18,2
0032 .dbline 70
0032 ; asm("nop");
0032 0000 nop
0034 .dbline 71
0034 ; asm("nop");
0034 0000 nop
0036 .dbline 72
0036 ; lcd_clear_e(); // Disable LCD
0036 C298 cbi 0x18,2
0038 .dbline 73
0038 ; delay_nus(40);
0038 08E2 ldi R16,40
003A 10E0 ldi R17,0
003C 0E940000 xcall _delay_nus
0040 .dbline 74
0040 ; LCD_OP_PORT = 0x20;
0040 80E2 ldi R24,32
0042 88BB out 0x18,R24
0044 .dbline 75
0044 ; lcd_set_e(); // Write data to LCD
0044 C29A sbi 0x18,2
0046 .dbline 76
0046 ; asm("nop");
0046 0000 nop
0048 .dbline 77
0048 ; asm("nop");
0048 0000 nop
004A .dbline 78
004A ; lcd_clear_e(); // Disable LCD
004A C298 cbi 0x18,2
004C .dbline 79
004C ; delay_nus(40);
004C 08E2 ldi R16,40
004E 10E0 ldi R17,0
0050 .dbline -2
0050 L1:
0050 .dbline 0 ; func end
0050 0C940000 xjmp _delay_nus
0054 .dbend
0054 .dbfunc e LCD_Busy _LCD_Busy fV
0054 ; low -> R12
0054 ; high -> R10
0054 ; temp -> R20
.even
0054 _LCD_Busy::
0054 0E940000 xcall push_xgset303C
0058 .dbline -1
0058 .dbline 85
0058 ; }
0058 ; //*****************************************************//
0058 ; // This routine will return the busy flag from the LCD //
0058 ; //*****************************************************//
0058 ; void LCD_Busy ( void )
0058 ; {
0058 .dbline 88
0058 ; unsigned char temp,high;
0058 ; unsigned char low;
0058 ; LCD_DIR_PORT = 0x0f; // Make I/O Port input
0058 8FE0 ldi R24,15
005A 87BB out 0x17,R24
005C L3:
005C .dbline 90
005C ; do
005C ; {
005C .dbline 91
005C ; temp=LCD_OP_PORT;
005C 48B3 in R20,0x18
005E .dbline 92
005E ; temp=temp&BIT3;
005E 4870 andi R20,8
0060 .dbline 93
0060 ; LCD_OP_PORT=temp;
0060 48BB out 0x18,R20
0062 .dbline 94
0062 ; lcd_set_rw(); // Set LCD to READ
0062 C19A sbi 0x18,1
0064 .dbline 95
0064 ; lcd_clear_rs();
0064 C098 cbi 0x18,0
0066 .dbline 96
0066 ; lcd_set_e();
0066 C29A sbi 0x18,2
0068 .dbline 97
0068 ; delay_nus(3);
0068 03E0 ldi R16,3
006A 10E0 ldi R17,0
006C 0E940000 xcall _delay_nus
0070 .dbline 98
0070 ; high = LCD_IP_PORT; // read the high nibble.
0070 A6B2 in R10,0x16
0072 .dbline 99
0072 ; lcd_clear_e(); // Disable LCD
0072 C298 cbi 0x18,2
0074 .dbline 100
0074 ; lcd_set_e();
0074 C29A sbi 0x18,2
0076 .dbline 101
0076 ; asm("nop");
0076 0000 nop
0078 .dbline 102
0078 ; asm("nop");
0078 0000 nop
007A .dbline 103
007A ; low = LCD_IP_PORT; // read the low nibble.
007A C6B2 in R12,0x16
007C .dbline 104
007C ; lcd_clear_e(); // Disable LCD
007C C298 cbi 0x18,2
007E .dbline 105
007E ; } while(high & 0x80);
007E L4:
007E .dbline 105
007E A7FC sbrc R10,7
0080 EDCF rjmp L3
0082 X0:
0082 .dbline 106
0082 ; delay_nus(20);
0082 04E1 ldi R16,20
0084 10E0 ldi R17,0
0086 0E940000 xcall _delay_nus
008A .dbline -2
008A L2:
008A .dbline 0 ; func end
008A 0C940000 xjmp pop_xgset303C
008E .dbsym r low 12 c
008E .dbsym r high 10 c
008E .dbsym r temp 20 c
008E .dbend
008E .dbfunc e LCD_WriteControl _LCD_WriteControl fV
008E ; temp -> R20
008E ; CMD -> R22
.even
008E _LCD_WriteControl::
008E 4A93 st -y,R20
0090 6A93 st -y,R22
0092 602F mov R22,R16
0094 .dbline -1
0094 .dbline 112
0094 ; }
0094 ; // ********************************************** //
0094 ; // *** Write a control instruction to the LCD *** //
0094 ; // ********************************************** //
0094 ; void LCD_WriteControl (unsigned char CMD)
0094 ; {
0094 .dbline 114
0094 ; char temp;
0094 ; LCD_Busy(); // Test if LCD busy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -