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

📄 lcd.lis

📁 ATMEGA128控制4×6矩阵键盘,LCD1602 使用protues软件可仿真 附带图片可观看效果
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module LCD.c
                        .area text(rom, con, rel)
 0000                   .dbfile D:\ICCAVR~1\模块化~1\src\LCD.c
 0000                   .dbfunc e LCD_INIT _LCD_INIT fV
                        .even
 0000           _LCD_INIT::
 0000                   .dbline -1
 0000                   .dbline 52
 0000           ; // ************************************************
 0000           ; // *** LCD_4BIT Driver V1.1 ***
 0000           ; // *** LCD.C ***
 0000           ; // ************************************************
 0000           ; #include "common.h"
 0000           ; 
 0000           ; #define LCD_C
 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 PORTD
 0000           ; #define LCD_IP_PORT PIND
 0000           ; #define LCD_DIR_PORT DDRD
 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 81BB              out 0x11,R24
 0004                   .dbline 54
 0004           ; LCD_OP_PORT = 0x30; // Load high-data to port
 0004 80E3              ldi R24,48
 0006 82BB              out 0x12,R24
 0008                   .dbline 55
 0008           ; lcd_clear_rw(); // Set LCD to write
 0008 9198              cbi 0x12,1
 000A                   .dbline 56
 000A           ; lcd_clear_rs(); // Set LCD to command
 000A 9098              cbi 0x12,0
 000C                   .dbline 57
 000C           ; lcd_set_e(); // Write data to LCD
 000C 929A              sbi 0x12,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 9298              cbi 0x12,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 9198              cbi 0x12,1
 001E                   .dbline 63
 001E           ; lcd_clear_rs(); // Set LCD to command
 001E 9098              cbi 0x12,0
 0020                   .dbline 64
 0020           ; lcd_set_e(); // Write data to LCD
 0020 929A              sbi 0x12,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 9298              cbi 0x12,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 929A              sbi 0x12,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 9298              cbi 0x12,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 82BB              out 0x12,R24
 0044                   .dbline 75
 0044           ; lcd_set_e(); // Write data to LCD
 0044 929A              sbi 0x12,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 9298              cbi 0x12,2
 004C                   .dbline 79
 004C           ; delay_nus(40);
 004C 08E2              ldi R16,40
 004E 10E0              ldi R17,0
 0050 0E940000          xcall _delay_nus
 0054                   .dbline -2
 0054           L1:
 0054                   .dbline 0 ; func end
 0054 0895              ret
 0056                   .dbend
 0056                   .dbfunc e LCD_Busy _LCD_Busy fV
 0056           ;            low -> R12
 0056           ;           high -> R10
 0056           ;           temp -> R20
                        .even
 0056           _LCD_Busy::
 0056 0E940000          xcall push_xgset303C
 005A                   .dbline -1
 005A                   .dbline 85
 005A           ; }
 005A           ; //*****************************************************//
 005A           ; // This routine will return the busy flag from the LCD //
 005A           ; //*****************************************************//
 005A           ; void LCD_Busy ( void )
 005A           ; {
 005A                   .dbline 88
 005A           ; unsigned char temp,high;
 005A           ; unsigned char low;
 005A           ; LCD_DIR_PORT = 0x0f; // Make I/O Port input
 005A 8FE0              ldi R24,15
 005C 81BB              out 0x11,R24
 005E           L3:
 005E                   .dbline 90
 005E           ; do
 005E           ; {
 005E                   .dbline 91
 005E           ; temp=LCD_OP_PORT;
 005E 42B3              in R20,0x12
 0060                   .dbline 92
 0060           ; temp=temp&BIT3;
 0060 4870              andi R20,8
 0062                   .dbline 93
 0062           ; LCD_OP_PORT=temp;
 0062 42BB              out 0x12,R20
 0064                   .dbline 94
 0064           ; lcd_set_rw(); // Set LCD to READ
 0064 919A              sbi 0x12,1
 0066                   .dbline 95
 0066           ; lcd_clear_rs();
 0066 9098              cbi 0x12,0
 0068                   .dbline 96
 0068           ; lcd_set_e();
 0068 929A              sbi 0x12,2
 006A                   .dbline 97
 006A           ; delay_nus(3);
 006A 03E0              ldi R16,3
 006C 10E0              ldi R17,0
 006E 0E940000          xcall _delay_nus
 0072                   .dbline 98
 0072           ; high = LCD_IP_PORT; // read the high nibble.
 0072 A0B2              in R10,0x10
 0074                   .dbline 99
 0074           ; lcd_clear_e(); // Disable LCD
 0074 9298              cbi 0x12,2
 0076                   .dbline 100
 0076           ; lcd_set_e();
 0076 929A              sbi 0x12,2
 0078                   .dbline 101
 0078           ; asm("nop");
 0078 0000              nop
 007A                   .dbline 102
 007A           ; asm("nop");
 007A 0000              nop
 007C                   .dbline 103
 007C           ; low = LCD_IP_PORT; // read the low nibble.
 007C C0B2              in R12,0x10
 007E                   .dbline 104
 007E           ; lcd_clear_e(); // Disable LCD
 007E 9298              cbi 0x12,2
 0080                   .dbline 105
 0080           ; } while(high & 0x80);
 0080           L4:
 0080                   .dbline 105
 0080 A7FC              sbrc R10,7
 0082 EDCF              rjmp L3
 0084           X0:
 0084                   .dbline 106
 0084           ; delay_nus(20);
 0084 04E1              ldi R16,20
 0086 10E0              ldi R17,0
 0088 0E940000          xcall _delay_nus
 008C                   .dbline -2
 008C           L2:
 008C                   .dbline 0 ; func end
 008C 0C940000          xjmp pop_xgset303C
 0090                   .dbsym r low 12 c
 0090                   .dbsym r high 10 c
 0090                   .dbsym r temp 20 c
 0090                   .dbend
 0090                   .dbfunc e LCD_WriteControl _LCD_WriteControl fV
 0090           ;           temp -> R20
 0090           ;            CMD -> R22
                        .even
 0090           _LCD_WriteControl::
 0090 4A93              st -y,R20
 0092 6A93              st -y,R22
 0094 602F              mov R22,R16

⌨️ 快捷键说明

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