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

📄 164_test.s

📁 mega使用人少
💻 S
字号:
	.module _164_test.c
	.area text(rom, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\164_test.c
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.dbfunc e delay_1us _delay_1us fV
	.even
_delay_1us::
	.dbline -1
	.dbline 6
; /**********延时函数*****************/
; /*-----------------------------------------------
; delay_us	   :1us延时函数
; ------------------------------------------------*/
; void delay_1us(void)
; {
	.dbline 7
;  asm("nop");
	nop
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e delay_us _delay_us fV
;              t -> R20,R21
	.even
_delay_us::
	st -y,R20
	st -y,R21
	movw R20,R16
	.dbline -1
	.dbline 14
; }
; /*-----------------------------------------------
; delay_nus          :长延时函数
; 输入参数: t        :延时时间 us
; ------------------------------------------------*/
; void delay_us(unsigned int t)
; {
	xjmp L4
L3:
	.dbline 16
;  while(t--)
;   delay_1us();
	xcall _delay_1us
L4:
	.dbline 15
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L3
	tst R3
	brne L3
X0:
	.dbline -2
L2:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r t 20 i
	.dbend
	.dbfunc e delay_1ms _delay_1ms fV
;              i -> R16,R17
	.even
_delay_1ms::
	.dbline -1
	.dbline 22
; }
; /*----------------------------------------------
; delay_ms	   :1ms延时函数
; -----------------------------------------------*/
; void delay_1ms(void)
; {
	.dbline 24
;  unsigned int i;
;  for(i=0;i<1140;i++);
	clr R16
	clr R17
	xjmp L10
L7:
	.dbline 24
L8:
	.dbline 24
	subi R16,255  ; offset = 1
	sbci R17,255
L10:
	.dbline 24
	cpi R16,116
	ldi R30,4
	cpc R17,R30
	brlo L7
X1:
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e delay_ms _delay_ms fV
;              t -> R20,R21
	.even
_delay_ms::
	st -y,R20
	st -y,R21
	movw R20,R16
	.dbline -1
	.dbline 31
; }
; /*----------------------------------------------
; delay_nms          :长延时函数
; 输入参数: t        :延时时间 ms
; -----------------------------------------------*/
; void delay_ms(unsigned int t)
; {
	xjmp L13
L12:
	.dbline 33
;  while(t--)
;   delay_1ms();
	xcall _delay_1ms
L13:
	.dbline 32
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L12
	tst R3
	brne L12
X2:
	.dbline -2
L11:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r t 20 i
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
_Table::
	.blkb 2
	.area idata
	.byte 63,6
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.blkb 2
	.area idata
	.byte 91,'O
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.blkb 2
	.area idata
	.byte 'f,'m
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.blkb 2
	.area idata
	.byte 125,7
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.blkb 2
	.area idata
	.byte 127,'o
	.area data(ram, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\delay.h
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\164.h
	.dbsym e Table _Table A[10:10]c
	.area text(rom, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\164.h
	.dbfunc e Init_164 _Init_164 fV
	.even
_Init_164::
	.dbline -1
	.dbline 18
; //定义LS164管脚和led控制脚
; #define DDR_CLK    DDRA
; #define DDR_DATA   DDRA
; #define DDR_CLEAR  DDRA
; #define DDR_SEL    DDRC
; #define PORT_CLK   PORTA
; #define PORT_DATA  PORTA
; #define PORT_CLEAR PORTA
; #define PORT_SEL   PORTC
; #define CLK PA2
; #define DATA PA4
; #define CLEAR PA3
; #define SEL 0x3C
; 
; unsigned char Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
; 
; void Init_164()
; {
	.dbline 19
;  DDR_CLK|=(1<<CLK);      //164的时钟,数据,清零
	sbi 0x1a,2
	.dbline 20
;  DDR_DATA|=(1<<DATA);
	sbi 0x1a,4
	.dbline 21
;  DDR_CLEAR|=(1<<CLEAR);
	sbi 0x1a,3
	.dbline 22
;  DDR_SEL|=SEL;  //4位数码管选通端
	in R24,0x14
	ori R24,60
	out 0x14,R24
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Clear_164 _Clear_164 fV
	.even
_Clear_164::
	.dbline -1
	.dbline 26
; }
; 
; void Clear_164()
; {
	.dbline 27
;  PORT_CLEAR|=(1<<CLEAR); 
	sbi 0x1b,3
	.dbline -2
L16:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e write_164 _write_164 fV
;              n -> R20
;              i -> R16
	.even
_write_164::
	st -y,R20
	.dbline -1
	.dbline 31
; }
; 
; void write_164(unsigned char i)
; {
	.dbline 33
;   char n;
;   for(n=8;n>0;n--) 
	ldi R20,8
	xjmp L21
L18:
	.dbline 34
;   {
	.dbline 35
;    if(i&0x80) PORT_DATA|=(1<<DATA);
	sbrs R16,7
	rjmp L22
X3:
	.dbline 35
	sbi 0x1b,4
	xjmp L23
L22:
	.dbline 36
;    else   PORT_DATA&=~(1<<DATA);
	cbi 0x1b,4
L23:
	.dbline 37
;    NOP();
	nop
	.dbline 38
;    PORT_CLK|=(1<<CLK);
	sbi 0x1b,2
	.dbline 39
;    NOP();
	nop
	.dbline 40
;    PORT_CLK&=~(1<<CLK);
	cbi 0x1b,2
	.dbline 41
;    i=(i<<1);
	lsl R16
	.dbline 42
;   }   
L19:
	.dbline 33
	dec R20
L21:
	.dbline 33
	ldi R24,0
	cp R24,R20
	brlo L18
X4:
	.dbline -2
L17:
	.dbline 0 ; func end
	ld R20,y+
	ret
	.dbsym r n 20 c
	.dbsym r i 16 c
	.dbend
	.dbfunc e write_LED _write_LED fV
;            sel -> R22
;              i -> R20
;              p -> R10,R11
	.even
_write_LED::
	xcall push_xgsetF00C
	movw R10,R16
	.dbline -1
	.dbline 45
; }
; void write_LED(unsigned char *p)
; {
	.dbline 46
;  unsigned char i,sel=0x04;
	ldi R22,4
	.dbline 48
;   
;  for(i=0;i<4;i++)
	clr R20
	xjmp L28
L25:
	.dbline 49
;  {
	.dbline 50
;   write_164(Table[p[i]]);
	mov R30,R20
	clr R31
	add R30,R10
	adc R31,R11
	ldd R30,z+0
	clr R31
	ldi R24,<_Table
	ldi R25,>_Table
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _write_164
	.dbline 51
;   PORT_SEL&=(~sel);
	mov R2,R22
	com R2
	in R3,0x15
	and R3,R2
	out 0x15,R3
	.dbline 52
;   delay_ms(2);
	ldi R16,2
	ldi R17,0
	xcall _delay_ms
	.dbline 53
;   PORT_SEL|=SEL;
	in R24,0x15
	ori R24,60
	out 0x15,R24
	.dbline 54
;   sel=sel<<1;
	lsl R22
	.dbline 55
;  } 
L26:
	.dbline 48
	inc R20
L28:
	.dbline 48
	cpi R20,4
	brlo L25
X5:
	.dbline -2
L24:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
	.dbsym r sel 22 c
	.dbsym r i 20 c
	.dbsym r p 10 pc
	.dbend
	.area lit(rom, con, rel)
L30:
	.byte 1,2
	.byte 3,4
	.area text(rom, con, rel)
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\164.h
	.dbfile D:\mega16_32实验板资料\ICCAVR源程序\164\数码管\164_test.c
	.dbfunc e main _main fV
;           Date -> y+0
	.even
_main::
	sbiw R28,4
	.dbline -1
	.dbline 12
; //ICC-AVR application builder : 2008-11-11 16:14:49
; // Target : M16
; // Crystal: 8.0000Mhz
; 
; #include <iom16v.h>
; #include <macros.h>
; 
; #include "delay.h"
; #include "164.h"
; 
; void main(void)
; {
	.dbline 13
;  unsigned char Date[4]={1,2,3,4};
	ldi R24,<L30
	ldi R25,>L30
	movw R30,R28
	ldi R16,4
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 14
;  delay_ms(20);
	ldi R16,20
	ldi R17,0
	xcall _delay_ms
	.dbline 15
;  Init_164();
	xcall _Init_164
	.dbline 16
;  Clear_164();
	xcall _Clear_164
	xjmp L32
L31:
	.dbline 18
;  while(1)
;   write_LED(Date);   //显示1234*/
	movw R16,R28
	xcall _write_LED
L32:
	.dbline 17
	xjmp L31
X6:
	.dbline -2
L29:
	.dbline 0 ; func end
	adiw R28,4
	ret
	.dbsym l Date 0 A[4:4]c
	.dbend
; }

⌨️ 快捷键说明

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