📄 12864.lis
字号:
.module _12864.c
.area text(rom, con, rel)
0000 .dbfile G:\test\lcd\3\12864.c
0000 .dbfunc e port_init _port_init fV
.even
0000 _port_init::
0000 .dbline -1
0000 .dbline 25
0000 ; //ICC-AVR application builder : 2005-7-21 15:31:35
0000 ; // Target : M32
0000 ; // Crystal: internal RC:1.0000Mhz
0000 ;
0000 ; //description:液晶横放显示汉字
0000 ;
0000 ; #include <iom16v.h>
0000 ; #include <macros.h>
0000 ;
0000 ; /* lcd port define: connect to PORTB of MEGA32L */
0000 ; #define RS 0
0000 ; #define RW 1
0000 ; #define E 2
0000 ; #define CSA 3
0000 ; #define CSB 4
0000 ; #define RST 5
0000 ;
0000 ; /******************************************************************** */
0000 ; #define SETBIT(x,y) (x|=(1<<y)) //set bit y in byte x
0000 ; #define CLRBIT(x,y) (x&=(~(1<<y))) //clear bit y in byte x
0000 ; #define CHKBIT(x,y) (x&(1<<y)) //check bit y in byte x
0000 ; /******************************************************************** */
0000 ;
0000 ; void port_init(void)
0000 ; {
0000 .dbline 26
0000 ; PORTA = 0xFF;
0000 8FEF ldi R24,255
0002 8BBB out 0x1b,R24
0004 .dbline 27
0004 ; DDRA = 0xFF;
0004 8ABB out 0x1a,R24
0006 .dbline 28
0006 ; PORTB = 0xFF;
0006 88BB out 0x18,R24
0008 .dbline 29
0008 ; DDRB = 0xFF;
0008 87BB out 0x17,R24
000A .dbline 30
000A ; PORTC = 0xFF;
000A 85BB out 0x15,R24
000C .dbline 31
000C ; DDRC = 0xFF;
000C 84BB out 0x14,R24
000E .dbline 32
000E ; PORTD = 0xFF;
000E 82BB out 0x12,R24
0010 .dbline 33
0010 ; DDRD = 0xFF;
0010 81BB out 0x11,R24
0012 .dbline -2
0012 L1:
0012 .dbline 0 ; func end
0012 0895 ret
0014 .dbend
0014 .dbfunc e init_devices _init_devices fV
.even
0014 _init_devices::
0014 .dbline -1
0014 .dbline 38
0014 ; }
0014 ;
0014 ; //call this routine to initialise all peripherals
0014 ; void init_devices(void)
0014 ; {
0014 .dbline 40
0014 ; //stop errant interrupts until set up
0014 ; CLI(); //disable all interrupts
0014 F894 cli
0016 .dbline 41
0016 ; port_init();
0016 F4DF xcall _port_init
0018 .dbline 43
0018 ;
0018 ; MCUCR = 0x00;
0018 2224 clr R2
001A 25BE out 0x35,R2
001C .dbline 44
001C ; GICR = 0x00;
001C 2BBE out 0x3b,R2
001E .dbline 45
001E ; TIMSK = 0x00; //timer interrupt sources
001E 29BE out 0x39,R2
0020 .dbline 46
0020 ; SEI(); //re-enable interrupts
0020 7894 sei
0022 .dbline -2
0022 L2:
0022 .dbline 0 ; func end
0022 0895 ret
0024 .dbend
0024 .dbfunc e CheckState _CheckState fV
0024 ; dat -> <dead>
.even
0024 _CheckState::
0024 .dbline -1
0024 .dbline 54
0024 ; //all peripherals are now initialised
0024 ; }
0024 ;
0024 ; /*-----------------------------------------------------
0024 ; 状态检查函数,判断是否处于忙状态
0024 ; -------------------------------------------------------*/
0024 ; void CheckState()
0024 ; {
0024 .dbline 56
0024 ; unsigned char dat;
0024 ; CLRBIT(PORTB,RS); //RS=0
0024 C098 cbi 0x18,0
0026 .dbline 57
0026 ; SETBIT(PORTB,RW); //RW=1
0026 C19A sbi 0x18,1
0028 .dbline 58
0028 ; DDRA=0x00; // portA as input
0028 2224 clr R2
002A 2ABA out 0x1a,R2
002C L4:
002C .dbline 60
002C ; do
002C ; {
002C .dbline 61
002C ; SETBIT(PORTB,E);
002C C29A sbi 0x18,2
002E .dbline 62
002E ; CLRBIT(PORTB,E);
002E C298 cbi 0x18,2
0030 .dbline 63
0030 ; }
0030 L5:
0030 .dbline 64
0030 ; while (PINA&0x80);
0030 CF99 sbic 0x19,7
0032 FCCF rjmp L4
0034 .dbline -2
0034 L3:
0034 .dbline 0 ; func end
0034 0895 ret
0036 .dbsym l dat 1 c
0036 .dbend
0036 .dbfunc e WriteByte _WriteByte fV
0036 ; dat -> R20
.even
0036 _WriteByte::
0036 0E940000 xcall push_gset1
003A 402F mov R20,R16
003C .dbline -1
003C .dbline 72
003C ; }
003C ;
003C ; /*----------------------------------------------
003C ; 写显示数据
003C ; 形参dat:显示数据
003C ; -------------------------------------------------*/
003C ; void WriteByte(unsigned char dat)
003C ; {
003C .dbline 73
003C ; CheckState();
003C F3DF xcall _CheckState
003E .dbline 74
003E ; SETBIT(PORTB,RS);
003E C09A sbi 0x18,0
0040 .dbline 75
0040 ; CLRBIT(PORTB,RW);
0040 C198 cbi 0x18,1
0042 .dbline 76
0042 ; DDRA=0xff; //portA as output
0042 8FEF ldi R24,255
0044 8ABB out 0x1a,R24
0046 .dbline 77
0046 ; PORTA=dat;
0046 4BBB out 0x1b,R20
0048 .dbline 78
0048 ; SETBIT(PORTB,E);
0048 C29A sbi 0x18,2
004A .dbline 79
004A ; CLRBIT(PORTB,E);
004A C298 cbi 0x18,2
004C .dbline -2
004C L7:
004C 0E940000 xcall pop_gset1
0050 .dbline 0 ; func end
0050 0895 ret
0052 .dbsym r dat 20 c
0052 .dbend
0052 .dbfunc e SendCommandToLCD _SendCommandToLCD fV
0052 ; command -> R20
.even
0052 _SendCommandToLCD::
0052 0E940000 xcall push_gset1
0056 402F mov R20,R16
0058 .dbline -1
0058 .dbline 88
0058 ; }
0058 ;
0058 ;
0058 ; /*-------------------------------------------------
0058 ; 向LCD发送命令
0058 ; 形参command :命令
0058 ; --------------------------------------------------*/
0058 ; void SendCommandToLCD(unsigned char command)
0058 ; {
0058 .dbline 89
0058 ; CheckState();
0058 E5DF xcall _CheckState
005A .dbline 90
005A ; PORTB&=0xfc; //RS=0,RW=0
005A 88B3 in R24,0x18
005C 8C7F andi R24,252
005E 88BB out 0x18,R24
0060 .dbline 91
0060 ; DDRA=0xff; //portA as output
0060 8FEF ldi R24,255
0062 8ABB out 0x1a,R24
0064 .dbline 92
0064 ; PORTA=command;
0064 4BBB out 0x1b,R20
0066 .dbline 93
0066 ; SETBIT(PORTB,E);
0066 C29A sbi 0x18,2
0068 .dbline 94
0068 ; CLRBIT(PORTB,E);
0068 C298 cbi 0x18,2
006A .dbline -2
006A L8:
006A 0E940000 xcall pop_gset1
006E .dbline 0 ; func end
006E 0895 ret
0070 .dbsym r command 20 c
0070 .dbend
0070 .dbfunc e SetLine _SetLine fV
0070 ; line -> R20
.even
0070 _SetLine::
0070 0E940000 xcall push_gset1
0074 402F mov R20,R16
0076 .dbline -1
0076 .dbline 100
0076 ; }
0076 ;
0076 ; /*-------------------------------------------------*/
0076 ; //设定行地址(页)--X 0-7
0076 ; void SetLine(unsigned char line)
0076 ; {
0076 .dbline 101
0076 ; line=line & 0x07; // 0<=line<=7
0076 4770 andi R20,7
0078 .dbline 102
0078 ; line=line|0xb8; //1011 1xxx
0078 486B ori R20,184
007A .dbline 103
007A ; SendCommandToLCD(line);
007A 042F mov R16,R20
007C EADF xcall _SendCommandToLCD
007E .dbline -2
007E L9:
007E 0E940000 xcall pop_gset1
0082 .dbline 0 ; func end
0082 0895 ret
0084 .dbsym r line 20 c
0084 .dbend
0084 .dbfunc e SetColumn _SetColumn fV
0084 ; column -> R20
.even
0084 _SetColumn::
0084 0E940000 xcall push_gset1
0088 402F mov R20,R16
008A .dbline -1
008A .dbline 107
008A ; }
008A ; //设定列地址--Y 0-63
008A ; void SetColumn(unsigned char column)
008A ; {
008A .dbline 108
008A ; column=column &0x3f; // 0=<column<=63
008A 4F73 andi R20,63
008C .dbline 109
008C ; column=column | 0x40; //01xx xxxx
008C 4064 ori R20,64
008E .dbline 110
008E ; SendCommandToLCD(column);
008E 042F mov R16,R20
0090 E0DF xcall _SendCommandToLCD
0092 .dbline -2
0092 L10:
0092 0E940000 xcall pop_gset1
0096 .dbline 0 ; func end
0096 0895 ret
0098 .dbsym r column 20 c
0098 .dbend
0098 .dbfunc e SetStartLine _SetStartLine fV
0098 ; startline -> R20
.even
0098 _SetStartLine::
0098 0E940000 xcall push_gset1
009C 402F mov R20,R16
009E .dbline -1
009E .dbline 115
009E ; }
009E ;
009E ; //设定显示开始行--XX
009E ; void SetStartLine(unsigned char startline) //0--63
009E ; {
009E .dbline 116
009E ; startline=startline & 0x07; //??0x3f
009E 4770 andi R20,7
00A0 .dbline 117
00A0 ; startline=startline|0xc0; //1100 0000
00A0 406C ori R20,192
00A2 .dbline 118
00A2 ; SendCommandToLCD(startline);
00A2 042F mov R16,R20
00A4 D6DF xcall _SendCommandToLCD
00A6 .dbline -2
00A6 L11:
00A6 0E940000 xcall pop_gset1
00AA .dbline 0 ; func end
00AA 0895 ret
00AC .dbsym r startline 20 c
00AC .dbend
00AC .dbfunc e SetOnOff _SetOnOff fV
00AC ; onoff -> R20
.even
00AC _SetOnOff::
00AC 0E940000 xcall push_gset1
00B0 402F mov R20,R16
00B2 .dbline -1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -