📄 ks0108_12864lcd.lis
字号:
.module KS0108_12864LCD.C
.area text(rom, con, rel)
0000 .dbfile F:\Temp\KS0108_12864LCD\Source\KS0108_12864LCD.C
.area lit(rom, con, rel)
0000 _WELCOME:
0000 48656C6C6F2C20456D62656464656457 .byte 'H,'e,'l,'l,'o,44,32,'E,'m,'b,'e,'d,'d,'e,'d,'W
0010 6F726C642100 .byte 'o,'r,'l,'d,33,0
0016 .dbsym s WELCOME _WELCOME A[22:22]kc
0016 _WEBSITE:
0016 2A7777772E494345776F726B73686F70 .byte 42,'w,'w,'w,46,'I,'C,'E,'w,'o,'r,'k,'s,'h,'o,'p
0026 2E636F6D2A00 .byte 46,'c,'o,'m,42,0
002C .dbsym s WEBSITE _WEBSITE A[22:22]kc
.area text(rom, con, rel)
0000 .dbfile F:\Temp\KS0108_12864LCD\Source\KS0108_12864LCD.C
0000 .dbfunc s Delay_1ms _Delay_1ms fV
0000 ; i -> R16
.even
0000 _Delay_1ms:
0000 .dbline -1
0000 .dbline 82
0000 ; /*----------------------------------------------------------------------------*-
0000 ;
0000 ; Source Name : KS0108_12864LCD.C (v1.00)
0000 ;
0000 ; ----------------------------------------------------------------------------
0000 ; COPYRIGHT
0000 ; ---------
0000 ;
0000 ; Created date : 2008.03.01
0000 ; Created By : HOCHIEN
0000 ; Modified by :
0000 ; Modified Date :
0000 ; Version : 2.0
0000 ; Description : Simple KS0108 based 128 * 64 pixels LCD
0000 ; demonstration program.
0000 ;
0000 ; LCD LIBRARY CODE
0000 ;
0000 ; Designed for SuperLoop operation,
0000 ; in this case for a 64 * 128 pixels matrix LCD display.
0000 ;
0000 ; * * * This program is from : www.ICEworksop.com * * *
0000 ;
0000 ; -*----------------------------------------------------------------------------*/
0000 ;
0000 ; #include "Main.H"
0000 ; #include "Port.H"
0000 ;
0000 ; #include "KS0108_12864LCD.H"
0000 ;
0000 ; // ------ Public variable declarations ---------------------------------------
0000 ;
0000 ; // See 'FONT6x8.C' for details
0000 ; extern flash uInt8 FONT6x8[][6];
0000 ;
0000 ; // See 'Chinese_Text.C' for details
0000 ; extern flash uInt8 CN_WELCOME[][32];
0000 ; extern flash uInt8 CN_EMBEDDED[][32];
0000 ;
0000 ; // See 'Image_Test.C' for details
0000 ; extern flash uInt8 Image_Test[];
0000 ;
0000 ; // ------ Private constants --------------------------------------------------
0000 ;
0000 ; #define DISPLAY_ON 0x3F // 0011 1111
0000 ; #define DISPLAY_OFF 0x3E // 0011 1110
0000 ; #define DISPLAY_STARTLINE 0xC0 // 1100 0000
0000 ; #define DISPLAY_PAGE_SET 0xB8 // 1011 1000
0000 ; #define DISPLAY_COLUMN_SET 0x40 // 0100 0000
0000 ; #define LCD_BUSY 0x80
0000 ;
0000 ; #define INVERSE (1)
0000 ; #define NORMAL (0)
0000 ; #define D_DATA (1)
0000 ; #define COMMAND (0)
0000 ;
0000 ; static flash uInt8 WELCOME[] = "Hello, EmbeddedWorld!";
0000 ; static flash uInt8 WEBSITE[] = "*www.ICEworkshop.com*";
0000 ;
0000 ; // ------ Private function prototypes ----------------------------------------
0000 ;
0000 ; static void Delay_1ms(void);
0000 ; static void Clear_Screen(uInt8);
0000 ; static void LCD_Send_Byte(uInt8, uInt8, uInt8);
0000 ; static void LCD_Set_XY(uInt8, uInt8);
0000 ; static void LCD_Disp_a_Char(uInt8, uInt8, uInt8, uInt8);
0000 ; static void LCD_Disp_String(uInt8, uInt8, flash uInt8 *, uInt8);
0000 ; static void LCD_Disp_Chinese_String (uInt8, uInt8, uInt8, uInt8, uInt8, uInt8,
0000 ; flash uInt8 (*)[32], uInt8);
0000 ; static void LCD_Disp_an_Image(uInt8, uInt8, flash uInt8 *, uInt8, uInt8, uInt8);
0000 ; static void LCD_Draw_a_Dot(uInt8, uInt8, uInt8);
0000 ;
0000 ; /*----------------------------------------------------------------------------*-
0000 ;
0000 ; Delay_1ms()
0000 ;
0000 ; Software delay * approx * 1 millisecond @ 1MHz system clock.
0000 ;
0000 ; -*----------------------------------------------------------------------------*/
0000 ; #pragma ctask Delay_1ms
0000 ; static void Delay_1ms(void)
0000 ; {
0000 .dbline 84
0000 ; uInt8 i;
0000 ; for (i=0;i<143;i++);
0000 0027 clr R16
0002 01C0 xjmp L5
0004 L2:
0004 .dbline 84
0004 L3:
0004 .dbline 84
0004 0395 inc R16
0006 L5:
0006 .dbline 84
0006 0F38 cpi R16,143
0008 E8F3 brlo L2
000A X0:
000A .dbline -2
000A L1:
000A .dbline 0 ; func end
000A 0895 ret
000C .dbsym r i 16 c
000C .dbend
000C .dbfunc e KS0108_12864LCD_Init _KS0108_12864LCD_Init fV
.even
000C _KS0108_12864LCD_Init::
000C 2197 sbiw R28,1
000E .dbline -1
000E .dbline 95
000E ; }
000E ;
000E ; /*----------------------------------------------------------------------------*-
000E ;
000E ; KS0108_12864LCD_Init()
000E ;
000E ; Set up LCD controller KS0108 before use it.
000E ;
000E ; -*----------------------------------------------------------------------------*/
000E ; void KS0108_12864LCD_Init(void)
000E ; {
000E .dbline 97
000E ; // Set up the ports, see 'Port.H' for port pins details
000E ; LCD_DATA_PORT_DIR = OUTPUT; // LED data PORT is an output
000E 8FEF ldi R24,255
0010 8ABB out 0x1a,R24
0012 .dbline 98
0012 ; LCD_INSTR_PORT_DIR = OUTPUT; // LED instruction PORT is an output
0012 81BB out 0x11,R24
0014 .dbline 99
0014 ; LCD_DATA_PORT = 0x00;
0014 2224 clr R2
0016 2BBA out 0x1b,R2
0018 .dbline 102
0018 ;
0018 ; // Toggle reset
0018 ; LCD_INSTR_PORT |= LCD_RST;
0018 939A sbi 0x12,3
001A .dbline 103
001A ; Delay_1ms();
001A F2DF xcall _Delay_1ms
001C .dbline 105
001C ;
001C ; LCD_INSTR_PORT &= ~LCD_RST;
001C 9398 cbi 0x12,3
001E .dbline 106
001E ; Delay_1ms();
001E F0DF xcall _Delay_1ms
0020 .dbline 108
0020 ;
0020 ; LCD_INSTR_PORT |= LCD_RST;
0020 939A sbi 0x12,3
0022 .dbline 109
0022 ; Delay_1ms();
0022 EEDF xcall _Delay_1ms
0024 .dbline 112
0024 ;
0024 ; // Setup column select and initialize display
0024 ; LCD_INSTR_PORT |= LCD_CS1;
0024 949A sbi 0x12,4
0026 .dbline 113
0026 ; LCD_INSTR_PORT &= ~LCD_CS2;
0026 9598 cbi 0x12,5
0028 .dbline 115
0028 ;
0028 ; LCD_Send_Byte(DISPLAY_OFF, COMMAND, NORMAL); // Display OFF
0028 2224 clr R2
002A 2882 std y+0,R2
002C 2227 clr R18
002E 0EE3 ldi R16,62
0030 51D1 xcall _LCD_Send_Byte
0032 .dbline 116
0032 ; LCD_Send_Byte(DISPLAY_STARTLINE, COMMAND, NORMAL);
0032 2224 clr R2
0034 2882 std y+0,R2
0036 2227 clr R18
0038 00EC ldi R16,192
003A 4CD1 xcall _LCD_Send_Byte
003C .dbline 117
003C ; LCD_Send_Byte(DISPLAY_PAGE_SET, COMMAND, NORMAL);
003C 2224 clr R2
003E 2882 std y+0,R2
0040 2227 clr R18
0042 08EB ldi R16,184
0044 47D1 xcall _LCD_Send_Byte
0046 .dbline 118
0046 ; LCD_Send_Byte(DISPLAY_COLUMN_SET, COMMAND, NORMAL);
0046 2224 clr R2
0048 2882 std y+0,R2
004A 2227 clr R18
004C 00E4 ldi R16,64
004E 42D1 xcall _LCD_Send_Byte
0050 .dbline 119
0050 ; LCD_Send_Byte(DISPLAY_ON, COMMAND, NORMAL); // Display ON
0050 2224 clr R2
0052 2882 std y+0,R2
0054 2227 clr R18
0056 0FE3 ldi R16,63
0058 3DD1 xcall _LCD_Send_Byte
005A .dbline 121
005A ;
005A ; LCD_INSTR_PORT &= ~LCD_CS1;
005A 9498 cbi 0x12,4
005C .dbline 122
005C ; LCD_INSTR_PORT |= LCD_CS2;
005C 959A sbi 0x12,5
005E .dbline 124
005E ;
005E ; LCD_Send_Byte(DISPLAY_OFF, COMMAND, NORMAL); // Display OFF
005E 2224 clr R2
0060 2882 std y+0,R2
0062 2227 clr R18
0064 0EE3 ldi R16,62
0066 36D1 xcall _LCD_Send_Byte
0068 .dbline 125
0068 ; LCD_Send_Byte(DISPLAY_STARTLINE, COMMAND, NORMAL);
0068 2224 clr R2
006A 2882 std y+0,R2
006C 2227 clr R18
006E 00EC ldi R16,192
0070 31D1 xcall _LCD_Send_Byte
0072 .dbline 126
0072 ; LCD_Send_Byte(DISPLAY_PAGE_SET, COMMAND, NORMAL);
0072 2224 clr R2
0074 2882 std y+0,R2
0076 2227 clr R18
0078 08EB ldi R16,184
007A 2CD1 xcall _LCD_Send_Byte
007C .dbline 127
007C ; LCD_Send_Byte(DISPLAY_COLUMN_SET, COMMAND, NORMAL);
007C 2224 clr R2
007E 2882 std y+0,R2
0080 2227 clr R18
0082 00E4 ldi R16,64
0084 27D1 xcall _LCD_Send_Byte
0086 .dbline 128
0086 ; LCD_Send_Byte(DISPLAY_ON, COMMAND, NORMAL); // Display ON
0086 2224 clr R2
0088 2882 std y+0,R2
008A 2227 clr R18
008C 0FE3 ldi R16,63
008E 22D1 xcall _LCD_Send_Byte
0090 .dbline 130
0090 ;
0090 ; Clear_Screen(NORMAL);
0090 0027 clr R16
0092 D0D0 xcall _Clear_Screen
0094 .dbline -2
0094 L6:
0094 .dbline 0 ; func end
0094 2196 adiw R28,1
0096 0895 ret
0098 .dbend
0098 .dbfunc e KS0108_12864LCD_Update _KS0108_12864LCD_Update fV
0098 ; i -> R20,R21
0098 ; j -> R22,R23
.even
0098 _KS0108_12864LCD_Update::
0098 0E940000 xcall push_xgsetF000
009C 2B97 sbiw R28,11
009E .dbline -1
009E .dbline 141
009E ; }
009E ;
009E ; /*----------------------------------------------------------------------------*-
009E ;
009E ; PCD8544_LCD_Update()
009E ;
009E ; This function updates data on the LCD panel (if it requires update).
009E ;
009E ; -*----------------------------------------------------------------------------*/
009E ; void KS0108_12864LCD_Update(void)
009E ; {
009E .dbline 144
009E ; uInt16 i, j;
009E ;
009E ; LCD_Disp_an_Image(0, 0, Image_Test, 64, 128, NORMAL);
009E 2224 clr R2
00A0 2E82 std y+6,R2
00A2 80E8 ldi R24,128
00A4 8C83 std y+4,R24
00A6 80E4 ldi R24,64
00A8 8A83 std y+2,R24
00AA 80E0 ldi R24,<_Image_Test
00AC 90E0 ldi R25,>_Image_Test
00AE 9983 std y+1,R25
00B0 8883 std y+0,R24
00B2 2227 clr R18
00B4 0027 clr R16
00B6 CCD1 xcall _LCD_Disp_an_Image
00B8 .dbline 145
00B8 ; for(i = 0; i < 1000; i++)
00B8 4427 clr R20
00BA 5527 clr R21
00BC 0BC0 xjmp L11
00BE L8:
00BE .dbline 146
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -