📄 lcd.lis
字号:
.module LCD.c
.area text(rom, con, rel)
0000 .dbfile LCD.c
0000 .dbfile F:\file\数控电源3\ad_da\text\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 PORTC
0000 ; #define LCD_IP_PORT PINC
0000 ; #define LCD_DIR_PORT DDRC
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 84BB out 0x14,R24
0004 .dbline 54
0004 ; LCD_OP_PORT = 0x30; // Load high-data to port
0004 80E3 ldi R24,48
0006 85BB out 0x15,R24
0008 .dbline 55
0008 ; lcd_clear_rw(); // Set LCD to write
0008 A998 cbi 0x15,1
000A .dbline 56
000A ; lcd_clear_rs(); // Set LCD to command
000A A898 cbi 0x15,0
000C .dbline 57
000C ; lcd_set_e(); // Write data to LCD
000C AA9A sbi 0x15,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 AA98 cbi 0x15,2
0014 .dbline 61
0014 ; delay_nus(40);
0014 08E2 ldi R16,40
0016 10E0 ldi R17,0
0018 00D0 rcall _delay_nus
001A .dbline 62
001A ; lcd_clear_rw() ; // Set LCD to write
001A A998 cbi 0x15,1
001C .dbline 63
001C ; lcd_clear_rs(); // Set LCD to command
001C A898 cbi 0x15,0
001E .dbline 64
001E ; lcd_set_e(); // Write data to LCD
001E AA9A sbi 0x15,2
0020 .dbline 65
0020 ; asm("nop");
0020 0000 nop
0022 .dbline 66
0022 ; asm("nop");
0022 0000 nop
0024 .dbline 67
0024 ; lcd_clear_e(); // Disable LCD
0024 AA98 cbi 0x15,2
0026 .dbline 68
0026 ; delay_nus(40);
0026 08E2 ldi R16,40
0028 10E0 ldi R17,0
002A 00D0 rcall _delay_nus
002C .dbline 69
002C ; lcd_set_e(); // Write data to LCD
002C AA9A sbi 0x15,2
002E .dbline 70
002E ; asm("nop");
002E 0000 nop
0030 .dbline 71
0030 ; asm("nop");
0030 0000 nop
0032 .dbline 72
0032 ; lcd_clear_e(); // Disable LCD
0032 AA98 cbi 0x15,2
0034 .dbline 73
0034 ; delay_nus(40);
0034 08E2 ldi R16,40
0036 10E0 ldi R17,0
0038 00D0 rcall _delay_nus
003A .dbline 74
003A ; LCD_OP_PORT = 0x20;
003A 80E2 ldi R24,32
003C 85BB out 0x15,R24
003E .dbline 75
003E ; lcd_set_e(); // Write data to LCD
003E AA9A sbi 0x15,2
0040 .dbline 76
0040 ; asm("nop");
0040 0000 nop
0042 .dbline 77
0042 ; asm("nop");
0042 0000 nop
0044 .dbline 78
0044 ; lcd_clear_e(); // Disable LCD
0044 AA98 cbi 0x15,2
0046 .dbline 79
0046 ; delay_nus(40);
0046 08E2 ldi R16,40
0048 10E0 ldi R17,0
004A .dbline -2
004A L1:
004A .dbline 0 ; func end
004A 00C0 rjmp _delay_nus
004C .dbend
004C .dbfunc e LCD_Busy _LCD_Busy fV
004C ; low -> R12
004C ; high -> R10
004C ; temp -> R20
.even
004C _LCD_Busy::
004C 00D0 rcall push_xgset303C
004E .dbline -1
004E .dbline 85
004E ; }
004E ; //*****************************************************//
004E ; // This routine will return the busy flag from the LCD //
004E ; //*****************************************************//
004E ; void LCD_Busy ( void )
004E ; {
004E .dbline 88
004E ; unsigned char temp,high;
004E ; unsigned char low;
004E ; LCD_DIR_PORT = 0x0f; // Make I/O Port input
004E 8FE0 ldi R24,15
0050 84BB out 0x14,R24
0052 L3:
0052 .dbline 90
0052 ; do
0052 ; {
0052 .dbline 91
0052 ; temp=LCD_OP_PORT;
0052 45B3 in R20,0x15
0054 .dbline 92
0054 ; temp=temp&BIT3;
0054 4870 andi R20,8
0056 .dbline 93
0056 ; LCD_OP_PORT=temp;
0056 45BB out 0x15,R20
0058 .dbline 94
0058 ; lcd_set_rw(); // Set LCD to READ
0058 A99A sbi 0x15,1
005A .dbline 95
005A ; lcd_clear_rs();
005A A898 cbi 0x15,0
005C .dbline 96
005C ; lcd_set_e();
005C AA9A sbi 0x15,2
005E .dbline 97
005E ; delay_nus(3);
005E 03E0 ldi R16,3
0060 10E0 ldi R17,0
0062 00D0 rcall _delay_nus
0064 .dbline 98
0064 ; high = LCD_IP_PORT; // read the high nibble.
0064 A3B2 in R10,0x13
0066 .dbline 99
0066 ; lcd_clear_e(); // Disable LCD
0066 AA98 cbi 0x15,2
0068 .dbline 100
0068 ; lcd_set_e();
0068 AA9A sbi 0x15,2
006A .dbline 101
006A ; asm("nop");
006A 0000 nop
006C .dbline 102
006C ; asm("nop");
006C 0000 nop
006E .dbline 103
006E ; low = LCD_IP_PORT; // read the low nibble.
006E C3B2 in R12,0x13
0070 .dbline 104
0070 ; lcd_clear_e(); // Disable LCD
0070 AA98 cbi 0x15,2
0072 .dbline 105
0072 ; } while(high & 0x80);
0072 L4:
0072 .dbline 105
0072 A7FC sbrc R10,7
0074 EECF rjmp L3
0076 X0:
0076 .dbline 106
0076 ; delay_nus(20);
0076 04E1 ldi R16,20
0078 10E0 ldi R17,0
007A 00D0 rcall _delay_nus
007C .dbline -2
007C L2:
007C .dbline 0 ; func end
007C 00C0 rjmp pop_xgset303C
007E .dbsym r low 12 c
007E .dbsym r high 10 c
007E .dbsym r temp 20 c
007E .dbend
007E .dbfunc e LCD_WriteControl _LCD_WriteControl fV
007E ; temp -> R20
007E ; CMD -> R22
.even
007E _LCD_WriteControl::
007E 4A93 st -y,R20
0080 6A93 st -y,R22
0082 602F mov R22,R16
0084 .dbline -1
0084 .dbline 112
0084 ; }
0084 ; // ********************************************** //
0084 ; // *** Write a control instruction to the LCD *** //
0084 ; // ********************************************** //
0084 ; void LCD_WriteControl (unsigned char CMD)
0084 ; {
0084 .dbline 114
0084 ; char temp;
0084 ; LCD_Busy(); // Test if LCD busy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -