⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7segled.s

📁 键盘操作 键盘扫描 用的是单片机mega16
💻 S
字号:
	.module _7segled.c
	.area code(ram, con, rel)
	.area lit(rom, con, rel)
_Seg7_Data::
	.byte 63,6
	.byte 91,'O
	.byte 'f,'m
	.byte 125,7
	.byte 127,'o
	.byte 'w,124
	.byte 57,94
	.byte 'y,'q
	.byte 0
	.dbfile E:\democode\key_4\source\lib\7segled.c
	.dbsym e Seg7_Data _Seg7_Data A[17:17]kc
	.area data(ram, con, rel)
	.dbfile E:\democode\key_4\source\lib\7segled.c
	.area text(rom, con, rel)
	.dbfile E:\democode\key_4\source\lib\7segled.c
	.dbfunc e Seg7_Led_Init _Seg7_Led_Init fV
	.even
_Seg7_Led_Init::
	.dbline -1
	.dbline 17
; /************************************************
; 文件:7segled.c
; 用途:七段数码管驱动程序
; 注意:外部7.3728M晶振
; 创建:2008.1.26
; 修改:2008.1.26
; Copy Right  (c)  www.avrvi.com  AVR与虚拟仪器
; ************************************************/
; #include "..\config.h"
; #pragma data:code
; const unsigned char Seg7_Data[]={0x3F,0x06,0x5B,0x4F,0x66,             //0,1,2,3,4
;                          0x6D,0x7D,0x07,0x7F,0x6F,             //5,6,7,8,9
; 						 0x77,0x7C,0x39,0x5E,0x79,0x71,0x00};  //a,b,c,d,e,f
; #pragma data:data
; volatile unsigned char Seg7_Led_Buf[4];
; void Seg7_Led_Init(void)
; {
	.dbline 18
;  Seg7_Data_Ddr=0xff;
	ldi R24,255
	out 0x17,R24
	.dbline 19
;  Seg7_Data_Port=0x00;
	clr R2
	out 0x18,R2
	.dbline 20
;  Seg7_Bitselect_Port&=~((1<<Seg7_Bit0)|(1<<Seg7_Bit1)|(1<<Seg7_Bit2)|(1<<Seg7_Bit3));
	in R24,0x15
	andi R24,60
	out 0x15,R24
	.dbline 21
;  Seg7_Bitselect_Ddr|=((1<<Seg7_Bit0)|(1<<Seg7_Bit1)|(1<<Seg7_Bit2)|(1<<Seg7_Bit3));
	in R24,0x14
	ori R24,195
	out 0x14,R24
	.dbline 22
;  Seg7_Led_Buf[0]=16;
	ldi R24,16
	sts _Seg7_Led_Buf,R24
	.dbline 23
;  Seg7_Led_Buf[1]=16;
	sts _Seg7_Led_Buf+1,R24
	.dbline 24
;  Seg7_Led_Buf[2]=16;
	sts _Seg7_Led_Buf+2,R24
	.dbline 25
;  Seg7_Led_Buf[3]=16;
	sts _Seg7_Led_Buf+3,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Seg7_Led_Update _Seg7_Led_Update fV
	.even
_Seg7_Led_Update::
	.dbline -1
	.dbline 29
; }
; 
; void Seg7_Led_Update(void)
; {
	.dbline 30
;  Seg7_Data_Port=Seg7_Data[Seg7_Led_Buf[0]];
	ldi R24,<_Seg7_Data
	ldi R25,>_Seg7_Data
	lds R30,_Seg7_Led_Buf
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 31
;  Seg7_Bit0_En();
	.dbline 31
	sbi 0x14,7
	.dbline 31
	sbi 0x15,7
	.dbline 31
	.dbline 31
	.dbline 32
;  Delay100us(60);
	ldi R16,60
	xcall _Delay100us
	.dbline 33
;  Seg7_Bit0_Dis();
	.dbline 33
	sbi 0x14,7
	.dbline 33
	cbi 0x15,7
	.dbline 33
	.dbline 33
	.dbline 34
;  Seg7_Data_Port=Seg7_Data[Seg7_Led_Buf[1]];
	ldi R24,<_Seg7_Data
	ldi R25,>_Seg7_Data
	lds R30,_Seg7_Led_Buf+1
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 35
;  Seg7_Bit1_En();
	.dbline 35
	sbi 0x14,6
	.dbline 35
	sbi 0x15,6
	.dbline 35
	.dbline 35
	.dbline 36
;  Delay100us(60);
	ldi R16,60
	xcall _Delay100us
	.dbline 37
;  Seg7_Bit1_Dis();
	.dbline 37
	sbi 0x14,6
	.dbline 37
	cbi 0x15,6
	.dbline 37
	.dbline 37
	.dbline 38
;  Seg7_Data_Port=Seg7_Data[Seg7_Led_Buf[2]];
	ldi R24,<_Seg7_Data
	ldi R25,>_Seg7_Data
	lds R30,_Seg7_Led_Buf+2
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 39
;  Seg7_Bit2_En();
	.dbline 39
	sbi 0x14,1
	.dbline 39
	sbi 0x15,1
	.dbline 39
	.dbline 39
	.dbline 40
;  Delay100us(60);
	ldi R16,60
	xcall _Delay100us
	.dbline 41
;  Seg7_Bit2_Dis();
	.dbline 41
	sbi 0x14,1
	.dbline 41
	cbi 0x15,1
	.dbline 41
	.dbline 41
	.dbline 42
;  Seg7_Data_Port=Seg7_Data[Seg7_Led_Buf[3]];
	ldi R24,<_Seg7_Data
	ldi R25,>_Seg7_Data
	lds R30,_Seg7_Led_Buf+3
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 43
;  Seg7_Bit3_En();
	.dbline 43
	sbi 0x14,0
	.dbline 43
	sbi 0x15,0
	.dbline 43
	.dbline 43
	.dbline 44
;  Delay100us(60);
	ldi R16,60
	xcall _Delay100us
	.dbline 45
;  Seg7_Bit3_Dis(); 
	.dbline 45
	sbi 0x14,0
	.dbline 45
	cbi 0x15,0
	.dbline 45
	.dbline 45
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Seg7_Led_display _Seg7_Led_display fV
;           data -> R20,R21
	.even
_Seg7_Led_display::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 49
; }
; 
; void Seg7_Led_display(unsigned int data)
; {
	.dbline 50
;  Seg7_Led_Buf[3]=data/1000;
	ldi R18,1000
	ldi R19,3
	movw R16,R20
	xcall div16u
	sts _Seg7_Led_Buf+3,R16
	.dbline 51
;  Seg7_Led_Buf[2]=(data%1000)/100;
	ldi R18,1000
	ldi R19,3
	movw R16,R20
	xcall mod16u
	ldi R18,100
	ldi R19,0
	xcall div16u
	sts _Seg7_Led_Buf+2,R16
	.dbline 52
;  Seg7_Led_Buf[1]=(data%100)/10;
	ldi R18,100
	ldi R19,0
	movw R16,R20
	xcall mod16u
	ldi R18,10
	ldi R19,0
	xcall div16u
	sts _Seg7_Led_Buf+1,R16
	.dbline 53
;  Seg7_Led_Buf[0]=data%10;
	ldi R18,10
	ldi R19,0
	movw R16,R20
	xcall mod16u
	sts _Seg7_Led_Buf,R16
	.dbline 54
;  Seg7_Led_Update();
	xcall _Seg7_Led_Update
	.dbline -2
L9:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 i
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\democode\key_4\source\lib\7segled.c
_Seg7_Led_Buf::
	.blkb 4
	.dbsym e Seg7_Led_Buf _Seg7_Led_Buf A[4:4]c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -