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

📄 lcd.lis

📁 键盘扫描及其LCD显示输出,有源程序与仿真文件,都测试通过.
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module LCD.c
                        .area text(rom, con, rel)
 0000                   .dbfile F:\AVR练习\key_lcd\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           ; #define LCD_C
 0000           ; #include <io8535v.h>
 0000           ; #include"lcd.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 00D0              rcall _delay_nus
 001A                   .dbline 62
 001A           ; lcd_clear_rw() ; // Set LCD to write
 001A C198              cbi 0x18,1
 001C                   .dbline 63
 001C           ; lcd_clear_rs(); // Set LCD to command
 001C C098              cbi 0x18,0
 001E                   .dbline 64
 001E           ; lcd_set_e(); // Write data to LCD
 001E C29A              sbi 0x18,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 C298              cbi 0x18,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 C29A              sbi 0x18,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 C298              cbi 0x18,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 88BB              out 0x18,R24
 003E                   .dbline 75
 003E           ; lcd_set_e(); // Write data to LCD
 003E C29A              sbi 0x18,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 C298              cbi 0x18,2
 0046                   .dbline 79
 0046           ; delay_nus(40);
 0046 08E2              ldi R16,40
 0048 10E0              ldi R17,0
 004A 00D0              rcall _delay_nus
 004C                   .dbline -2
 004C           L1:
 004C                   .dbline 0 ; func end
 004C 0895              ret
 004E                   .dbend
 004E                   .dbfunc e LCD_Busy _LCD_Busy fV
 004E           ;            low -> R20
 004E           ;           high -> R22
 004E           ;           temp -> R10
                        .even
 004E           _LCD_Busy::
 004E 00D0              rcall push_gset3
 0050                   .dbline -1
 0050                   .dbline 85
 0050           ; }
 0050           ; //*****************************************************//
 0050           ; // This routine will return the busy flag from the LCD //
 0050           ; //*****************************************************//
 0050           ; void LCD_Busy ( void )
 0050           ; {
 0050                   .dbline 88
 0050           ; unsigned char temp,high;
 0050           ; unsigned char low;
 0050           ; LCD_DIR_PORT = 0x0f; // Make I/O Port input
 0050 8FE0              ldi R24,15
 0052 87BB              out 0x17,R24
 0054           L3:
 0054                   .dbline 90
 0054           ; do
 0054           ; {
 0054                   .dbline 91
 0054           ; temp=LCD_OP_PORT;
 0054 A8B2              in R10,0x18
 0056                   .dbline 92
 0056           ; temp=temp&BIT3;
 0056 8A2D              mov R24,R10
 0058 8870              andi R24,8
 005A A82E              mov R10,R24
 005C                   .dbline 93
 005C           ; LCD_OP_PORT=temp;
 005C 88BB              out 0x18,R24
 005E                   .dbline 94
 005E           ; lcd_set_rw(); // Set LCD to READ
 005E C19A              sbi 0x18,1
 0060                   .dbline 95
 0060           ; lcd_clear_rs();
 0060 C098              cbi 0x18,0
 0062                   .dbline 96
 0062           ; lcd_set_e();
 0062 C29A              sbi 0x18,2
 0064                   .dbline 97
 0064           ; delay_nus(3);
 0064 03E0              ldi R16,3
 0066 10E0              ldi R17,0
 0068 00D0              rcall _delay_nus
 006A                   .dbline 98
 006A           ; high = LCD_IP_PORT; // read the high nibble.
 006A 66B3              in R22,0x16
 006C                   .dbline 99
 006C           ; lcd_clear_e(); // Disable LCD
 006C C298              cbi 0x18,2
 006E                   .dbline 100
 006E           ; lcd_set_e();
 006E C29A              sbi 0x18,2
 0070                   .dbline 101
 0070           ; asm("nop");
 0070 0000              nop
 0072                   .dbline 102
 0072           ; asm("nop");
 0072 0000              nop
 0074                   .dbline 103
 0074           ; low = LCD_IP_PORT; // read the low nibble.
 0074 46B3              in R20,0x16
 0076                   .dbline 104
 0076           ; lcd_clear_e(); // Disable LCD
 0076 C298              cbi 0x18,2
 0078                   .dbline 105
 0078           L4:
 0078                   .dbline 105
 0078           ; } while(high & 0x80);
 0078 67FD              sbrc R22,7
 007A ECCF              rjmp L3
 007C                   .dbline 106
 007C           ; delay_nus(20);
 007C 04E1              ldi R16,20
 007E 10E0              ldi R17,0
 0080 00D0              rcall _delay_nus
 0082                   .dbline -2
 0082           L2:
 0082 00D0              rcall pop_gset3
 0084                   .dbline 0 ; func end
 0084 0895              ret
 0086                   .dbsym r low 20 c
 0086                   .dbsym r high 22 c
 0086                   .dbsym r temp 10 c
 0086                   .dbend
 0086                   .dbfunc e LCD_WriteControl _LCD_WriteControl fV
 0086           ;           temp -> R20
 0086           ;            CMD -> R22
                        .even
 0086           _LCD_WriteControl::
 0086 00D0              rcall push_gset2
 0088 602F              mov R22,R16
 008A                   .dbline -1
 008A                   .dbline 112
 008A           ; }
 008A           ; // ********************************************** //
 008A           ; // *** Write a control instruction to the LCD *** //
 008A           ; // ********************************************** //
 008A           ; void LCD_WriteControl (unsigned char CMD)
 008A           ; {
 008A                   .dbline 114
 008A           ; char temp;
 008A           ; LCD_Busy(); // Test if LCD busy
 008A E1DF              rcall _LCD_Busy
 008C                   .dbline 115
 008C           ; LCD_DIR_PORT = 0xff; // LCD port output

⌨️ 快捷键说明

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