📄 adclcd.lst
字号:
__start:
__text_start:
003B E5CF LDI R28,0x5F
003C E0D4 LDI R29,4
003D BFCD OUT 0x3D,R28
003E BFDE OUT 0x3E,R29
003F 51C0 SUBI R28,0x10
0040 40D0 SBCI R29,0
0041 EA0A LDI R16,0xAA
0042 8308 STD Y+0,R16
0043 2400 CLR R0
0044 E7E1 LDI R30,0x71
0045 E0F0 LDI R31,0
0046 E010 LDI R17,0
0047 37E4 CPI R30,0x74
0048 07F1 CPC R31,R17
0049 F011 BEQ 0x004C
004A 9201 ST R0,Z+
004B CFFB RJMP 0x0047
004C 8300 STD Z+0,R16
004D E6E4 LDI R30,0x64
004E E0F0 LDI R31,0
004F E6A0 LDI R26,0x60
0050 E0B0 LDI R27,0
0051 E010 LDI R17,0
0052 37E5 CPI R30,0x75
0053 07F1 CPC R31,R17
0054 F021 BEQ 0x0059
0055 95C8 LPM
0056 9631 ADIW R30,1
0057 920D ST R0,X+
0058 CFF9 RJMP 0x0052
0059 940E01DF CALL _main
_exit:
005B CFFF RJMP _exit
FILE: G:\AVRsource\adc\numled.c
(0001) /*******************************************/
(0002) /* 广州天河双龙电子公司 */
(0003) /* http://www.sl.com.cn */
(0004) /* 数码LED驱动程序 */
(0005) /* 作者:ntzwq@wx88.net */
(0006) /* 2002年5月11日 */
(0007) /* 目标MCU:MEGA8 晶振:内部RC(INT) 8MHZ */
(0008) /*******************************************/
(0009) #include<iom16v.h>
(0010) const unsigned char seg_table[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
(0011) 0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
(0012) unsigned char led_buff[4]={0,0,0,0};
(0013) /* 微秒级延时程序 */
(0014) void delay_us(int time)
(0015) {
(0016) do
(0017) {
(0018) time--;
_delay_us:
time --> R16
005C 5001 SUBI R16,1
005D 4010 SBCI R17,0
(0019) }
(0020) while (time>1);
005E E081 LDI R24,1
005F E090 LDI R25,0
0060 1780 CP R24,R16
0061 0791 CPC R25,R17
0062 F3CC BLT 0x005C
0063 9508 RET
_delay_ms:
time --> R20
0064 940E0344 CALL push_gset1
0066 01A8 MOVW R20,R16
(0021) }
(0022) /* 毫秒级延时程序 */
(0023) void delay_ms(unsigned int time)
(0024) {
0067 C005 RJMP 0x006D
(0025) while(time!=0)
(0026) {
(0027) delay_us(1000);
0068 EE08 LDI R16,0xE8
0069 E013 LDI R17,3
006A DFF1 RCALL _delay_us
(0028) time--;
006B 5041 SUBI R20,1
006C 4050 SBCI R21,0
006D 3040 CPI R20,0
006E 0745 CPC R20,R21
006F F7C1 BNE 0x0068
0070 940E0347 CALL pop_gset1
0072 9508 RET
_display:
i --> R20
0073 940E0344 CALL push_gset1
(0029) }
(0030) }
(0031) void display(void)
(0032) {
(0033) unsigned char i;
(0034) DDRB=0xff;
0075 EF8F LDI R24,0xFF
0076 BB87 OUT 0x17,R24
(0035) PORTB=0xff;
0077 BB88 OUT 0x18,R24
(0036) DDRD|=0xf0;
0078 B381 IN R24,0x11
0079 6F80 ORI R24,0xF0
007A BB81 OUT 0x11,R24
(0037) PORTD|=0xf0;
007B B382 IN R24,0x12
007C 6F80 ORI R24,0xF0
007D BB82 OUT 0x12,R24
(0038) for(i=0;i<4;i++)
007E 2744 CLR R20
007F C019 RJMP 0x0099
(0039) {
(0040) PORTB=led_buff[i];
0080 E680 LDI R24,0x60
0081 E090 LDI R25,0
0082 2FE4 MOV R30,R20
0083 27FF CLR R31
0084 0FE8 ADD R30,R24
0085 1FF9 ADC R31,R25
0086 8020 LDD R2,Z+0
0087 BA28 OUT 0x18,R2
(0041) PORTD&=~(1<<(i+4));
0088 2F14 MOV R17,R20
0089 5F1C SUBI R17,0xFC
008A E001 LDI R16,1
008B 940E0390 CALL lsl8
008D 2E20 MOV R2,R16
008E 9420 COM R2
008F B232 IN R3,0x12
0090 2032 AND R3,R2
0091 BA32 OUT 0x12,R3
(0042) delay_ms(1);
0092 E001 LDI R16,1
0093 E010 LDI R17,0
0094 DFCF RCALL _delay_ms
(0043) PORTD|=0xf0;
0095 B382 IN R24,0x12
0096 6F80 ORI R24,0xF0
0097 BB82 OUT 0x12,R24
0098 9543 INC R20
0099 3044 CPI R20,4
009A F328 BCS 0x0080
009B 940E0347 CALL pop_gset1
009D 9508 RET
FILE: G:\AVRsource\adc\1602.c
(0001) #include <iom16v.h>
(0002) #include <macros.h>
(0003) #define LCD_EN_PORT PORTC
(0004) #define LCD_RW_PORT PORTC
(0005) #define LCD_RS_PORT PORTC
(0006) #define LCD_DATA_PORT PORTB
(0007) #define LCD_DATA_DDR DDRB
(0008) #define LCD_DATA_PIN PINB
(0009) #define LCD_EN 0x80 //portd7 out
(0010) #define LCD_RS 0x40 //portc6 out
(0011) #define LCD_DATA 0xf0 //portb4/5/6/7 out
(0012)
(0013) /*--------------------------------------------------------------------------------------------------
(0014) Public function prototypes
(0015) --------------------------------------------------------------------------------------------------*/
(0016) void LCD_init (void);
(0017) void LCD_en_write (void);
(0018) void LCD_write_char (unsigned command,unsigned data);
(0019) void LCD_set_xy (unsigned char x, unsigned char y);
(0020) void LCD_write_string (unsigned char X,unsigned char Y,unsigned char *s);
(0021) void delay_nus (unsigned int n);
(0022) void delay_nms (unsigned int n);
(0023) void LCD_init(void) //液晶初始化
(0024) {
(0025) DDRB|=LCD_DATA; // 数据为输出
_LCD_init:
009E B387 IN R24,0x17
009F 6F80 ORI R24,0xF0
00A0 BB87 OUT 0x17,R24
(0026) DDRC|=LCD_RS|LCD_EN; //置位RS.EN
00A1 B384 IN R24,0x14
00A2 6C80 ORI R24,0xC0
00A3 BB84 OUT 0x14,R24
(0027) delay_nms(15);
00A4 E00F LDI R16,0xF
00A5 E010 LDI R17,0
00A6 D0AF RCALL _delay_nms
(0028) LCD_write_char(0x28,0); //4位显示
00A7 2722 CLR R18
00A8 2733 CLR R19
00A9 E208 LDI R16,0x28
00AA E010 LDI R17,0
00AB D03D RCALL _LCD_write_char
(0029) LCD_write_char(0x0c,0); //显示开
00AC 2722 CLR R18
00AD 2733 CLR R19
00AE E00C LDI R16,0xC
00AF E010 LDI R17,0
00B0 D038 RCALL _LCD_write_char
(0030) LCD_write_char(0x01,0); //清屏
00B1 2722 CLR R18
00B2 2733 CLR R19
00B3 E001 LDI R16,1
00B4 E010 LDI R17,0
00B5 D033 RCALL _LCD_write_char
00B6 9508 RET
_LCD_write_string:
s --> R20
Y --> R10
X --> R22
00B7 940E0340 CALL push_gset3
00B9 2EA2 MOV R10,R18
00BA 2F60 MOV R22,R16
00BB 814E LDD R20,Y+6
00BC 815F LDD R21,Y+7
(0031) }
(0032) void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
(0033) {
(0034) LCD_set_xy( X, Y ); //写地址
00BD 2D2A MOV R18,R10
00BE 2F06 MOV R16,R22
00BF D010 RCALL _LCD_set_xy
00C0 C008 RJMP 0x00C9
(0035)
(0036) while (*s) // 写显示字符
(0037) {
(0038) LCD_write_char( 0, *s );
00C1 01FA MOVW R30,R20
00C2 8120 LDD R18,Z+0
00C3 2733 CLR R19
00C4 2700 CLR R16
00C5 2711 CLR R17
00C6 D022 RCALL _LCD_write_char
(0039) s ++;
00C7 5F4F SUBI R20,0xFF
00C8 4F5F SBCI R21,0xFF
00C9 01FA MOVW R30,R20
00CA 8020 LDD R2,Z+0
00CB 2022 TST R2
00CC F7A1 BNE 0x00C1
00CD 940E0336 CALL pop_gset3
00CF 9508 RET
_LCD_set_xy:
address --> R20
y --> R20
x --> R22
00D0 940E0342 CALL push_gset2
00D2 2F42 MOV R20,R18
00D3 2F60 MOV R22,R16
(0040) }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -