📄 lcd1602new.lis
字号:
.module lcd1602new.c
.area lit(rom, con, rel)
0000 _dis1::
0000 4156522044656D6F20426F61726400 .byte 'A,'V,'R,32,'D,'e,'m,'o,32,'B,'o,'a,'r,'d,0
000F .dbfile C:\DOCUME~1\shen\桌面\lcd1602new.c
000F .dbsym e dis1 _dis1 A[15:15]kc
000F _dis2::
000F 39386469616E403136332E636F6D00 .byte 57,56,'d,'i,'a,'n,64,49,54,51,46,'c,'o,'m,0
001E .dbsym e dis2 _dis2 A[15:15]kc
.area text(rom, con, rel)
0000 .dbfile C:\DOCUME~1\shen\桌面\lcd1602new.c
0000 .dbfunc e delay _delay fV
0000 ; i -> R20,R21
0000 ; ms -> R16
.even
0000 _delay::
0000 0E940000 xcall push_gset1
0004 .dbline -1
0004 .dbline 28
0004 ; #include <iom16v.h>
0004 ; #include <macros.h>
0004 ;
0004 ;
0004 ; #define Enableon PORTB |=BIT(3); //EN
0004 ; #define Enableoff PORTB &=~BIT(3);
0004 ;
0004 ; #define Dion PORTB |=BIT(5); //DI
0004 ; #define Dioff PORTB &=~BIT(5);
0004 ;
0004 ; #define RWon PORTB |=BIT(4); //RW
0004 ; #define RWoff PORTB &=~BIT(4);
0004 ;
0004 ;
0004 ;
0004 ;
0004 ; extern const unsigned char dis1[] = {"AVR Demo Board"};
0004 ; extern const unsigned char dis2[] = {"98dian@163.com"};
0004 ;
0004 ; /****************************************************************************
0004 ; 函数功能:延时子程序
0004 ; 作 者:沈建良
0004 ; 时 间:2006年4月25日
0004 ; 入口参数:ms
0004 ; 出口参数:
0004 ; ****************************************************************************/
0004 ; void delay(unsigned char ms)
0004 ; { // 延时子程序
0004 0CC0 xjmp L3
0006 L2:
0006 .dbline 31
0006 ; int i;
0006 ; while(ms--)
0006 ; {
0006 .dbline 32
0006 ; for(i = 0; i< 250; i++)
0006 4427 clr R20
0008 5527 clr R21
000A L5:
000A .dbline 33
000A .dbline 34
000A 0000 nop
000C .dbline 35
000C 0000 nop
000E .dbline 36
000E 0000 nop
0010 .dbline 37
0010 0000 nop
0012 .dbline 38
0012 L6:
0012 .dbline 32
0012 4F5F subi R20,255 ; offset = 1
0014 5F4F sbci R21,255
0016 .dbline 32
0016 4A3F cpi R20,250
0018 E0E0 ldi R30,0
001A 5E07 cpc R21,R30
001C B4F3 brlt L5
001E .dbline 39
001E L3:
001E .dbline 30
001E 202E mov R2,R16
0020 3324 clr R3
0022 0150 subi R16,1
0024 2220 tst R2
0026 79F7 brne L2
0028 .dbline -2
0028 L1:
0028 0E940000 xcall pop_gset1
002C .dbline 0 ; func end
002C 0895 ret
002E .dbsym r i 20 I
002E .dbsym r ms 16 c
002E .dbend
002E .dbfunc e LCD_wait _LCD_wait fV
.even
002E _LCD_wait::
002E .dbline -1
002E .dbline 51
002E ; {
002E ; NOP();
002E ; NOP();
002E ; NOP();
002E ; NOP();
002E ; }
002E ; }
002E ; }
002E ;
002E ;
002E ; /****************************************************************************
002E ; 函数功能:测试LCD忙碌状态
002E ; 作 者:沈建良
002E ; 时 间:2006年4月25日
002E ; 入口参数:
002E ; 出口参数:result
002E ; ****************************************************************************/
002E ; void LCD_wait(void) //等待LCD空闲
002E ; {
002E .dbline 52
002E ; DDRC=0x00;
002E 2224 clr R2
0030 24BA out 0x14,R2
0032 .dbline 53
0032 ; Dioff;//RS
0032 C598 cbi 0x18,5
0034 .dbline 53
0034 .dbline 54
0034 ; RWon;
0034 C49A sbi 0x18,4
0036 .dbline 54
0036 .dbline 55
0036 ; NOP();
0036 0000 nop
0038 .dbline 56
0038 ; Enableon;
0038 C39A sbi 0x18,3
003A .dbline 56
003A L10:
003A .dbline 60
003A L11:
003A .dbline 60
003A ; //DDRC=0x00; //input
003A ; //delay(10);
003A ; //while(PINC&0x80);
003A ; while(PINC&0x80);
003A 9F99 sbic 0x13,7
003C FECF rjmp L10
003E .dbline 61
003E ; Enableoff;
003E C398 cbi 0x18,3
0040 .dbline 61
0040 .dbline 62
0040 ; DDRC=0xff; //output
0040 8FEF ldi R24,255
0042 84BB out 0x14,R24
0044 .dbline -2
0044 L9:
0044 .dbline 0 ; func end
0044 0895 ret
0046 .dbend
0046 .dbfunc e write_command _write_command fV
0046 ; cmd -> R20
.even
0046 _write_command::
0046 0E940000 xcall push_gset1
004A 402F mov R20,R16
004C .dbline -1
004C .dbline 74
004C ; }
004C ;
004C ;
004C ; /****************************************************************************
004C ; 函数功能:写指令数据到LCD
004C ; 作 者:沈建良
004C ; 时 间:2006年4月25日
004C ; 入口参数:cmd
004C ; 出口参数:
004C ; ****************************************************************************/
004C ; void write_command(unsigned char cmd) //写指令使能
004C ; {
004C .dbline 75
004C ; LCD_wait();
004C F0DF xcall _LCD_wait
004E .dbline 77
004E ; //delay(100);
004E ; Dioff;
004E C598 cbi 0x18,5
0050 .dbline 77
0050 .dbline 78
0050 ; RWoff;
0050 C498 cbi 0x18,4
0052 .dbline 78
0052 .dbline 79
0052 ; Enableoff;
0052 C398 cbi 0x18,3
0054 .dbline 79
0054 .dbline 80
0054 ; NOP();
0054 0000 nop
0056 .dbline 82
0056 ; //delay(10);
0056 ; Enableon;//???
0056 C39A sbi 0x18,3
0058 .dbline 82
0058 .dbline 85
0058 ; //DDRC=0xff; //output
0058 ; //delay(10);
0058 ; PORTC=cmd;
0058 45BB out 0x15,R20
005A .dbline 89
005A ; //delay(10);
005A ; //Enableon;
005A ; //delay(10);
005A ; Enableoff;
005A C398 cbi 0x18,3
005C .dbline 89
005C .dbline -2
005C L13:
005C 0E940000 xcall pop_gset1
0060 .dbline 0 ; func end
0060 0895 ret
0062 .dbsym r cmd 20 c
0062 .dbend
0062 .dbfunc e lcd_pos _lcd_pos fV
0062 ; pos -> R20
.even
0062 _lcd_pos::
0062 0E940000 xcall push_gset1
0066 402F mov R20,R16
0068 .dbline -1
0068 .dbline 100
0068 ; }
0068 ;
0068 ; /****************************************************************************
0068 ; 函数功能:设定显示位置
0068 ; 作 者:沈建良
0068 ; 时 间:2006年4月25日
0068 ; 入口参数:pos
0068 ; 出口参数:
0068 ; ****************************************************************************/
0068 ; void lcd_pos(unsigned char pos)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -