?? stklcd.lst
字號:
__start:
__text_start:
00C2 E5CF LDI R28,0x5F
00C3 E0D2 LDI R29,2
00C4 BFCD OUT P3D,R28
00C5 BFDE OUT P3E,R29
00C6 51CE SUBI R28,0x1E
00C7 40D0 SBCI R29,0
00C8 EA0A LDI R16,0xAA
00C9 8308 STD R16,0+Y
00CA 2400 CLR R0
00CB ECE7 LDI R30,0xC7
00CC E0F0 LDI R31,0
00CD E011 LDI R17,1
00CE 30E2 CPI R30,2
00CF 07F1 CPC R31,R17
00D0 F011 BEQ 0x00D3
00D1 9201 ST R0,Z+
00D2 CFFB RJMP 0x00CE
00D3 8300 STD R16,0+Z
00D4 E1ED LDI R30,0x1D
00D5 E0F1 LDI R31,1
00D6 E6A0 LDI R26,0x60
00D7 E0B0 LDI R27,0
00D8 E011 LDI R17,1
00D9 38E4 CPI R30,0x84
00DA 07F1 CPC R31,R17
00DB F021 BEQ 0x00E0
00DC 95C8 LPM
00DD 9631 ADIW R30,1
00DE 920D ST R0,X+
00DF CFF9 RJMP 0x00D9
00E0 D001 RCALL _main
_exit:
00E1 CFFF RJMP _exit
FILE: E:\work\avr\icc\cpld\stklcd\main.c
(0001) //
(0002) // File Name: main.c
(0003) //
(0004) // Title: Application entry point / driver
(0005) //
(0006) // Description: Main driver for LCD demo.
(0007) //
(0008) // Creation Date: 2/2/00 11:49:37 PM
(0009) //
(0010) // By: A.C. Verbeck
(0011) //
(0012) // This file is subject to the terms and conditions of the GNU General Public
(0013) // License. See the file COPYING in the main directory of this archive
(0014) // for more details.
(0015) //
(0016)
(0017) #include <io8515v.h>
(0018) #include <stdio.h>
(0019) #include <macros.h>
(0020)
(0021) #include "BaseType.h"
(0022) #include "lcd.h"
(0023) #include "t0.h"
(0024)
(0025) static void Timer_Test(void);
(0026) static void LCD_Test1(void);
(0027) static void LCD_Test2(void);
(0028)
(0029) static Char pbuff[32];
(0030)
(0031) void main(void)
(0032) {
(0033) SEI(); // Turn on the interrupts
_main:
00E2 9478 BSET 7
(0034) MCUCR = 0xc0; // Enable External RAM
00E3 EC80 LDI R24,0xC0
00E4 BF85 OUT P35,R24
(0035)
(0036) LCD_Test1(); // Do LCD test #2
(0037) }
00E5 C011 RJMP _LCD_Test1
_Timer_Test:
pb_val --> R20
00E6 D30B RCALL push_gset1
(0038)
(0039) static void Timer_Test(void)
(0040) {
(0041) UInt8 pb_val;
(0042)
(0043) DDRB = 0xff;
00E7 EF8F LDI R24,0xFF
00E8 BB87 OUT P17,R24
(0044) PORTB = 0x00;
00E9 2422 CLR R2
00EA BA28 OUT P18,R2
(0045) T0_init();
00EB D0E1 RCALL _T0_init
(0046) pb_val = 0;
00EC 2744 CLR R20
(0047) TASK_LOOP {
(0048) T0_sleep(10);
00ED E00A LDI R16,0xA
00EE E010 LDI R17,0
00EF D10E RCALL _T0_sleep
(0049) ++pb_val;
00F0 9543 INC R20
(0050) PORTB=~pb_val;
00F1 2E24 MOV R2,R20
00F2 9420 COM R2
00F3 BA28 OUT P18,R2
00F4 CFF8 RJMP 0x00ED
00F5 D2FF RCALL pop_gset1
00F6 9508 RET
_LCD_Test1:
i --> R20
00F7 D2FA RCALL push_gset1
00F8 9722 SBIW R28,2
(0051) }
(0052) }
(0053)
(0054) static void LCD_Test1(void)
(0055) {
(0056) UInt16 i;
(0057)
(0058) T0_init();
00F9 D0D3 RCALL _T0_init
(0059)
(0060) LCD_reset();
00FA D062 RCALL _LCD_reset
(0061) LCD_init();
00FB D04D RCALL _LCD_init
(0062) LCD_command(LCD_HOME);
00FC E002 LDI R16,2
00FD D071 RCALL _LCD_command
(0063) sprintf(pbuff, "Test display");
00FE E62B LDI R18,0x6B
00FF E030 LDI R19,0
0100 EC07 LDI R16,0xC7
0101 E010 LDI R17,0
0102 D3AD RCALL _sprintf
(0064) LCD_puts(pbuff);
0103 EC07 LDI R16,0xC7
0104 E010 LDI R17,0
0105 D07E RCALL _LCD_puts
(0065) LCD_command(LCD_NEW_LINE);
0106 EC00 LDI R16,0xC0
0107 D067 RCALL _LCD_command
(0066)
(0067) i=0;
0108 2744 CLR R20
0109 2755 CLR R21
(0068) TASK_LOOP {
(0069) T0_sleep(100);
010A E604 LDI R16,0x64
010B E010 LDI R17,0
010C D0F1 RCALL _T0_sleep
(0070) ++i;
010D 5F4F SUBI R20,0xFF
010E 4F5F SBCI R21,0xFF
(0071) sprintf(pbuff, "Value = %d",i);
010F 8348 STD R20,0+Y
0110 8359 STD R21,1+Y
0111 E620 LDI R18,0x60
0112 E030 LDI R19,0
0113 EC07 LDI R16,0xC7
0114 E010 LDI R17,0
0115 D39A RCALL _sprintf
(0072) LCD_puts(pbuff);
0116 EC07 LDI R16,0xC7
0117 E010 LDI R17,0
0118 D06B RCALL _LCD_puts
(0073) LCD_command(LCD_NEW_LINE);
0119 EC00 LDI R16,0xC0
011A D054 RCALL _LCD_command
011B CFEE RJMP 0x010A
011C 9622 ADIW R28,2
011D D2D7 RCALL pop_gset1
011E 9508 RET
_LCD_Test2:
i --> R20
011F D2D2 RCALL push_gset1
(0074) }
(0075) }
(0076)
(0077)
(0078) static void LCD_Test2(void)
(0079) {
(0080) UInt16 i;
(0081)
(0082) T0_init();
0120 D0AC RCALL _T0_init
(0083)
(0084) LCD_reset();
0121 D03B RCALL _LCD_reset
(0085) LCD_init();
0122 D026 RCALL _LCD_init
(0086) LCD_command(LCD_HOME);
0123 E002 LDI R16,2
0124 D04A RCALL _LCD_command
(0087)
(0088) TASK_LOOP {
(0089) for (i=0x20; i<0x80; i++) {
0125 E240 LDI R20,0x20
0126 E050 LDI R21,0
0127 C01A RJMP 0x0142
(0090) LCD_putc(i);
0128 2F04 MOV R16,R20
0129 D04D RCALL _LCD_putc
(0091) T0_sleep(500);
012A EF04 LDI R16,0xF4
012B E011 LDI R17,1
012C D0D1 RCALL _T0_sleep
(0092) if ((i%16) == 0) {
012D 2F84 MOV R24,R20
012E 2F95 MOV R25,R21
012F 708F ANDI R24,0xF
0130 7090 ANDI R25,0
0131 3080 CPI R24,0
0132 0789 CPC R24,R25
0133 F461 BNE 0x0140
(0093) if ((i%32) == 0)
0134 2F84 MOV R24,R20
0135 2F95 MOV R25,R21
0136 718F ANDI R24,0x1F
0137 7090 ANDI R25,0
0138 3080 CPI R24,0
0139 0789 CPC R24,R25
013A F419 BNE 0x013E
(0094) LCD_command(LCD_HOME);
013B E002 LDI R16,2
013C D032 RCALL _LCD_command
013D C002 RJMP 0x0140
(0095) else
(0096) LCD_command(LCD_NEW_LINE);
013E EC00 LDI R16,0xC0
013F D02F RCALL _LCD_command
0140 5F4F SUBI R20,0xFF
0141 4F5F SBCI R21,0xFF
0142 3840 CPI R20,0x80
0143 E0E0 LDI R30,0
0144 075E CPC R21,R30
0145 F310 BCS 0x0128
0146 CFDE RJMP 0x0125
0147 D2AD RCALL pop_gset1
0148 9508 RET
_LCD_init:
i --> R20
0149 D2A8 RCALL push_gset1
FILE: E:\work\avr\icc\cpld\stklcd\lcd.c
(0001) //
(0002) // File Name: lcd.c
(0003) //
(0004) // Title: LCD interface implementation
(0005) //
(0006) // Description: Interface implementation file for the Hitachi HD44780U.
(0007) // This driver is for the STK200.
(0008) // STK200 port information
(0009) // DATA = PORTA
(0010) // RS = PORTC BIT 6
(0011) // R/W = PORTD BIT 6
(0012) // E = PORTC BIT 7
(0013) //
(0014) // Creation Date: 2/2/00 11:49:37 PM
(0015) //
(0016) // By: A.C. Verbeck
(0017) //
(0018) // This file is subject to the terms and conditions of the GNU General Public
(0019) // License. See the file COPYING in the main directory of this archive
(0020) // for more details.
(0021) //
(0022)
(0023) #include <io8515v.h>
(0024) #include <stdio.h>
(0025)
(0026) #include "Basetype.h"
(0027) #include "t0.h"
(0028)
(0029) #include "lcd.h"
(0030)
(0031) //
(0032) // Local defines
(0033) //
(0034) #define FUNCTION_SET 0x38
(0035) #define CMD 0x00
(0036) #define DATA 0x01
(0037) #define CMD_IO (PUInt8)0x8000
(0038) #define DATA_IO (PUInt8)0xC000
(0039)
(0040) //
(0041) // Local data
(0042) //
(0043) static UInt8 init_tab[] = {
(0044) FUNCTION_SET,
(0045) LCD_CLEAR,
(0046) LCD_OFF,
(0047) LCD_ON,
(0048) LCD_CLEAR
(0049) };
(0050)
(0051) //
(0052) // Local functions
(0053) //
(0054) static void LCD_write(UInt8 val, UInt8 sel);
(0055) static UInt8 LCD_read(UInt8 sel);
(0056) static void LCD_busy_test(void);
(0057) static void delay(UInt16 dly);
(0058)
(0059) //
(0060) // Function Name:
(0061) // LCD_init
(0062) //
(0063) // Description:
(0064) // Initialize the LCD.
(0065) //
(0066) // Parameters:
(0067) // (none)
(0068) //
(0069) // Returns:
(0070) // (nothing)
(0071) //
(0072) void LCD_init(void)
(0073) {
(0074) UInt8 i;
(0075)
(0076) for (i=0; i<5; i++) {
014A 2744 CLR R20
014B C00B RJMP 0x0157
(0077) LCD_busy_test();
014C D07B RCALL _LCD_busy_test
(0078) LCD_write(init_tab[i], CMD);
014D 2722 CLR R18
014E E788 LDI R24,0x78
014F E090 LDI R25,0
0150 2FE4 MOV R30,R20
0151 27FF CLR R31
0152 0FE8 ADD R30,R24
0153 1FF9 ADC R31,R25
0154 8100 LDD R16,0+Z
0155 D049 RCALL _LCD_write
0156 9543 INC R20
0157 3045 CPI R20,5
0158 F398 BCS 0x014C
(0079) }
(0080) }
0159 D29B RCALL pop_gset1
015A 9508 RET
(0081)
(0082) //
(0083) // Function Name:
(0084) // LCD_clear
(0085) //
(0086) // Description:
(0087) // Clear the LCD.
(0088) //
(0089) // Parameters:
(0090) // (none)
(0091) //
(0092) // Returns:
(0093) // (nothing)
(0094) //
(0095) void LCD_clear(void)
(0096) {
(0097) LCD_command(LCD_CLEAR);
_LCD_clear:
015B E001 LDI R16,1
(0098) }
015C C012 RJMP _LCD_command
(0099)
(0100) //
(0101) // Function Name:
(0102) // LCD_reset
(0103) //
(0104) // Description:
(0105) // Reset the LCD.
(0106) //
(0107) // Parameters:
(0108) // (none)
(0109) //
(0110) // Returns:
(0111) // (nothing)
(0112) //
(0113) void LCD_reset(void)
(0114) {
(0115) T0_sleep(15); // Hitachi says wait 15mS before writing the LCD
_LCD_reset:
015D E00F LDI R16,0xF
015E E010 LDI R17,0
015F D09E RCALL _T0_sleep
(0116) LCD_write(0x30, CMD); // Write the init (first time)
0160 2722 CLR R18
0161 E300 LDI R16,0x30
0162 D03C RCALL _LCD_write
(0117) T0_sleep(5); // Then, wait 4.1mS
0163 E005 LDI R16,5
0164 E010 LDI R17,0
0165 D098 RCALL _T0_sleep
(0118) LCD_write(0x30, CMD); // Write the init again (second time)
0166 2722 CLR R18
0167 E300 LDI R16,0x30
0168 D036 RCALL _LCD_write
(0119) T0_sleep(1); // Then, wait 100uS
0169 E001 LDI R16,1
016A E010 LDI R17,0
016B D092 RCALL _T0_sleep
(0120) LCD_write(0x30, CMD); // Write the init again (last time)
016C 2722 CLR R18
016D E300 LDI R16,0x30
(0121) }
016E C030 RJMP _LCD_write
_LCD_command:
data --> R20
016F D282 RCALL push_gset1
0170 2F40 MOV R20,R16
(0122)
(0123) void LCD_command(UInt8 data)
(0124) {
(0125) LCD_busy_test();
0171 D056 RCALL _LCD_busy_test
(0126) LCD_write(data, CMD);
0172 2722 CLR R18
0173 2F04 MOV R16,R20
0174 D02A RCALL _LCD_write
(0127) }
0175 D27F RCALL pop_gset1
0176 9508 RET
_LCD_putc:
c --> R20
0177 D27A RCALL push_gset1
0178 2F40 MOV R20,R16
(0128)
(0129) void LCD_putc(Char c)
(0130) {
(0131) LCD_busy_test();
0179 D04E RCALL _LCD_busy_test
(0132) if (c == '\n')
017A 304A CPI R20,0xA
017B F419 BNE 0x017F
(0133) LCD_command(LCD_NEW_LINE);
017C EC00 LDI R16,0xC0
017D DFF1 RCALL _LCD_command
017E C003 RJMP 0x0182
(0134) else
(0135) LCD_write(c, DATA);
017F E021 LDI R18,1
0180 2F04 MOV R16,R20
0181 D01D RCALL _LCD_write
(0136) }
0182 D272 RCALL pop_gset1
0183 9508 RET
_LCD_puts:
s --> R20
0184 D26D RCALL push_gset1
0185 2F40 MOV R20,R16
0186 2F51 MOV R21,R17
(0137)
(0138) void LCD_puts(String s)
(0139) {
0187 C010 RJMP 0x0198
(0140) while (*s) {
(0141) LCD_busy_test();
0188 D03F RCALL _LCD_busy_test
(0142) if (*s == '\n')
0189 2FE4 MOV R30,R20
018A 2FF5 MOV R31,R21
018B 8180 LDD R24,0+Z
018C 308A CPI R24,0xA
018D F419 BNE 0x0191
(0143) LCD_command(LCD_NEW_LINE);
018E EC00 LDI R16,0xC0
018F DFDF RCALL _LCD_command
0190 C005 RJMP 0x0196
(0144) else
(0145) LCD_write(*s, DATA);
0191 E021 LDI R18,1
0192 2FE4 MOV R30,R20
0193 2FF5 MOV R31,R21
0194 8100 LDD R16,0+Z
0195 D009 RCALL _LCD_write
(0146) ++s;
0196 5F4F SUBI R20,0xFF
0197 4F5F SBCI R21,0xFF
0198 2FE4 MOV R30,R20
0199 2FF5 MOV R31,R21
019A 8020 LDD R2,0+Z
019B 2022 TST R2
019C F759 BNE 0x0188
(0147) }
(0148) }
019D D257 RCALL pop_gset1
019E 9508 RET
_LCD_write:
sel --> R18
val --> R16
019F D252 RCALL push_gset1
(0149)
(0150)
(0151) //
(0152) // Function Name:
(0153) // LCD_write
(0154) //
(0155) // Description:
(0156) // Write data or cmd to HD44780U
(0157) //
(0158) // Parameters:
(0159) // val = data value to be written to HD44780U
(0160) // sel = data / cmd
(0161) // 0 - cmd write
(0162) // 1 - data write is selected
(0163) //
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -