📄 lcd.lis
字号:
.module LCD.c
.area text(rom, con, rel)
0000 .dbfile D:\仿真\增量式模糊控制\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 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 -> R20
0056 ; high -> R22
0056 ; temp -> R10
.even
0056 _LCD_Busy::
0056 0E940000 xcall push_gset3
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 87BB out 0x17,R24
005E L3:
005E .dbline 90
005E ; do
005E ; {
005E .dbline 91
005E ; temp=LCD_OP_PORT;
005E A8B2 in R10,0x18
0060 .dbline 92
0060 ; temp=temp&BIT3;
0060 8A2D mov R24,R10
0062 8870 andi R24,8
0064 A82E mov R10,R24
0066 .dbline 93
0066 ; LCD_OP_PORT=temp;
0066 88BB out 0x18,R24
0068 .dbline 94
0068 ; lcd_set_rw(); // Set LCD to READ
0068 C19A sbi 0x18,1
006A .dbline 95
006A ; lcd_clear_rs();
006A C098 cbi 0x18,0
006C .dbline 96
006C ; lcd_set_e();
006C C29A sbi 0x18,2
006E .dbline 97
006E ; delay_nus(3);
006E 03E0 ldi R16,3
0070 10E0 ldi R17,0
0072 0E940000 xcall _delay_nus
0076 .dbline 98
0076 ; high = LCD_IP_PORT; // read the high nibble.
0076 66B3 in R22,0x16
0078 .dbline 99
0078 ; lcd_clear_e(); // Disable LCD
0078 C298 cbi 0x18,2
007A .dbline 100
007A ; lcd_set_e();
007A C29A sbi 0x18,2
007C .dbline 101
007C ; asm("nop");
007C 0000 nop
007E .dbline 102
007E ; asm("nop");
007E 0000 nop
0080 .dbline 103
0080 ; low = LCD_IP_PORT; // read the low nibble.
0080 46B3 in R20,0x16
0082 .dbline 104
0082 ; lcd_clear_e(); // Disable LCD
0082 C298 cbi 0x18,2
0084 .dbline 105
0084 L4:
0084 .dbline 105
0084 ; } while(high & 0x80);
0084 67FD sbrc R22,7
0086 EBCF rjmp L3
0088 .dbline 106
0088 ; delay_nus(20);
0088 04E1 ldi R16,20
008A 10E0 ldi R17,0
008C 0E940000 xcall _delay_nus
0090 .dbline -2
0090 L2:
0090 0E940000 xcall pop_gset3
0094 .dbline 0 ; func end
0094 0895 ret
0096 .dbsym r low 20 c
0096 .dbsym r high 22 c
0096 .dbsym r temp 10 c
0096 .dbend
0096 .dbfunc e LCD_WriteControl _LCD_WriteControl fV
0096 ; temp -> R20
0096 ; CMD -> R22
.even
0096 _LCD_WriteControl::
0096 0E940000 xcall push_gset2
009A 602F mov R22,R16
009C .dbline -1
009C .dbline 112
009C ; }
009C ; // ********************************************** //
009C ; // *** Write a control instruction to the LCD *** //
009C ; // ********************************************** //
009C ; void LCD_WriteControl (unsigned char CMD)
009C ; {
009C .dbline 114
009C ; char temp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -