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

📄 main.s

📁 用AVR atmega16做的一个完整彩色LED控制程序
💻 S
📖 第 1 页 / 共 5 页
字号:
L6:
	.dbline 423
	.dbline 424
	nop
	.dbline 425
	nop
	.dbline 426
	nop
	.dbline 427
L7:
	.dbline 422
	dec R22
L9:
	.dbline 422
	clr R2
	cp R2,R22
	brlo L6
	.dbline 430
	wdr
	.dbline 432
L3:
	.dbline 420
	inc R20
L5:
	.dbline 420
	cp R20,R16
	brlo L2
	.dbline -2
L1:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r i 22 c
	.dbsym r tim 16 c
	.dbend
	.dbfunc e DelayNs _DelayNs fV
;              j -> R20
;            tim -> R16
	.even
_DelayNs::
	xcall push_gset1
	.dbline -1
	.dbline 435
; 	   	   {
; 		   	   asm("nop");
; 			   asm("nop");
; 			   asm("nop");
; 		   }
; #ifdef VERSION_CONTROL
; 	/* WDT 复位*/
; 	_WDR();
; #endif
; 	   }
; }
; void   DelayNs(char tim)
; {
	.dbline 437
;  	   unsigned char j;
; 	   for(j=0;j<tim;j++)
	clr R20
	xjmp L14
L11:
	.dbline 438
	.dbline 439
	nop
	.dbline 440
	nop
	.dbline 441
	nop
	.dbline 442
L12:
	.dbline 437
	inc R20
L14:
	.dbline 437
	cp R20,R16
	brlo L11
	.dbline 445
; 	   {
; 	   	   asm("nop");
; 		   asm("nop");
; 		   asm("nop");
; 	   }
; #ifdef VERSION_CONTROL
; 	/* WDT 复位*/
; 	_WDR();
	wdr
	.dbline -2
L10:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r tim 16 c
	.dbend
	.dbfunc e SendSS _SendSS fV
;           loop -> R20
	.even
_SendSS::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 450
; #endif
; }
; 
; void		SendSS(uchar loop )
; {
	.dbline 451
; 	if(loop==0) return;
	tst R20
	brne L16
	.dbline 451
	xjmp L15
L16:
	.dbline 452
; 	PORTB |= 0x10; //SS output  high 电平 
	sbi 0x18,4
	.dbline 453
; 	DelayNs(20);
	ldi R16,20
	xcall _DelayNs
	.dbline 454
; 	PORTB &=(~0x10); //SS  output  low 电平 
	cbi 0x18,4
	.dbline -2
L15:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r loop 20 c
	.dbend
	.dbfunc e SendSI _SendSI fV
;              i -> R20
;           loop -> R22
	.even
_SendSI::
	xcall push_gset2
	mov R22,R16
	.dbline -1
	.dbline 458
; }
; 
; void		SendSI(uchar loop)
; {
	.dbline 460
; 	uchar	i;
; 	if(loop==0) return;
	tst R22
	brne L19
	.dbline 460
	xjmp L18
L19:
	.dbline 461
; 	for(i=0;i<loop;i++)
	clr R20
	xjmp L24
L21:
	.dbline 462
	.dbline 463
	sbi 0x18,3
	.dbline 464
	xcall _Display_Fast
	.dbline 465
	cbi 0x18,3
	.dbline 466
	xcall _Display_Fast
	.dbline 467
L22:
	.dbline 461
	inc R20
L24:
	.dbline 461
	cp R20,R22
	brlo L21
	.dbline -2
L18:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r loop 22 c
	.dbend
	.dbfunc e hmod _hmod fi
;              i -> R20
;            src -> R22
;           dest -> R18,R19
;         source -> R16,R17
	.even
_hmod::
	xcall push_gset2
	.dbline -1
	.dbline 470
; 	{
; 		PORTB |= 0x08; //S_I  output  high 电平 
; 		Display_Fast();
; 		PORTB &=(~0x08); //S_I  output  low 电平 
; 		Display_Fast();
; 	}
; }
; uint	hmod(uint source,uint dest)
; {
	.dbline 472
; 	uchar	i,src;
; 	src=source;
	mov R22,R16
	.dbline 473
; 	if(src<dest) return src;
	mov R2,R22
	clr R3
	cp R2,R18
	cpc R3,R19
	brsh L26
	.dbline 473
	clr R17
	xjmp L25
L26:
	.dbline 474
; 	for(i=0;i<source;i++)
	clr R20
	xjmp L31
L28:
	.dbline 475
; 	{
	.dbline 476
; 		src=src-dest;
	mov R2,R22
	clr R3
	sub R2,R18
	sbc R3,R19
	mov R22,R2
	.dbline 477
; 		if(src<dest) break;
	clr R3
	cp R2,R18
	cpc R3,R19
	brsh L32
	.dbline 477
	xjmp L30
L32:
	.dbline 478
L29:
	.dbline 474
	inc R20
L31:
	.dbline 474
	mov R2,R20
	clr R3
	cp R2,R16
	cpc R3,R17
	brlo L28
L30:
	.dbline 479
; 	}
; 	return src;
	mov R16,R22
	clr R17
	.dbline -2
L25:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r src 22 c
	.dbsym r dest 18 i
	.dbsym r source 16 i
	.dbend
	.dbfunc e Send_Data _Send_Data fV
;              i -> R20
;           loop -> R22
;            dat -> R10
	.even
_Send_Data::
	xcall push_gset3
	mov R22,R18
	mov R10,R16
	.dbline -1
	.dbline 483
; }
; 
; void		Send_Data(uchar  dat,uchar loop )
; {
	.dbline 485
; 	uchar i;
; 	for(i=0;i<loop;i++)
	clr R20
	xjmp L38
L35:
	.dbline 486
	.dbline 487
	mov R16,R10
	xcall _putSPIchar
	.dbline 488
	ldi R16,50
	xcall _DelayNs
	.dbline 489
L36:
	.dbline 485
	inc R20
L38:
	.dbline 485
	cp R20,R22
	brlo L35
	.dbline -2
L34:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r loop 22 c
	.dbsym r dat 10 c
	.dbend
	.dbfunc e PasswordCannel _PasswordCannel fV
	.even
_PasswordCannel::
	.dbline -1
	.dbline 493
; 	{
; 		putSPIchar(dat);
; 		DelayNs(50);
; 	}	
; }
; 
; void		PasswordCannel(void)
; {
	.dbline 494
; 	PasswordData[0]=PASS_DISABLE;
	ldi R24,255
	sts _PasswordData,R24
	.dbline 495
; 	PasswordData[1]=PASS_DISABLE;
	sts _PasswordData+1,R24
	.dbline 496
; 	PasswordData[2]=PASS_DISABLE;
	sts _PasswordData+2,R24
	.dbline 497
; 	PasswordData[3]=PASS_DISABLE;
	sts _PasswordData+3,R24
	.dbline 498
; 	PasswordData[4]=PASS_DISABLE;
	sts _PasswordData+4,R24
	.dbline 499
; 	PasswordData[5]=0x00;
	clr R2
	sts _PasswordData+5,R2
	.dbline 500
; 	Password_alarm=FALSE;
	sts _Password_alarm,R2
	.dbline 501
; 	Password_Enable=FALSE;
	sts _Password_Enable,R2
	.dbline -2
L39:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
_year1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e year1 _year1 c
_year0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e year0 _year0 c
_month1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e month1 _month1 c
_month0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e month0 _month0 c
_date0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e date0 _date0 c
_date1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e date1 _date1 c
_day::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e day _day c
_hour1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e hour1 _hour1 c
_hour0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e hour0 _hour0 c
_minute1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e minute1 _minute1 c
_minute0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e minute0 _minute0 c
_second1::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e second1 _second1 c
_second0::
	.blkb 1
	.area idata
	.byte 136
	.area data(ram, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbsym e second0 _second0 c
	.area text(rom, con, rel)
	.dbfile D:\Ledcontrol\test\main.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 570
; }
; 
; //mega16 7.3728MHz石英晶体 iccavr6.31a
; /*
; 去掉电池:
; year/mon/day =00/01/01
; hour/min/second=00/00/00
; 去掉芯片:
; year/mon/day =ff/1f/3f
; hour/min/second=3f/7f/7f
; 重新扦入芯片,永远为:
; year/mon/day =00/01/01
; hour/min/second=00/00/00
; */
; //相关定义:
; #define 	DS1302_RST 	2 //pd2
; #define 	DS1302_SDA 	0 //pd0
; #define 	DS1302_SCLK 	1 //pd1
; //ds1302相关
; //DS1302_RST=1
; #define 	Set_DS1302_RST() PORTD|=1<<DS1302_RST
; //DS1302_RST=0
; #define 	Clr_DS1302_RST() PORTD&=~(1<<DS1302_RST)
; //DS1302_SDA=1
; #define 	Set_DS1302_SDA() PORTD|=1<<DS1302_SDA
; //DS1302_SDA=0
; #define 	Clr_DS1302_SDA() PORTD&=~(1<<DS1302_SDA)
; //DS1302_SCLK=1
; #define 	Set_DS1302_SCLK() PORTD|=1<<DS1302_SCLK
; //DS1302_SCLK=0
; #define 	Clr_DS1302_SCLK() PORTD&=~(1<<DS1302_SCLK)
; //DS1302的SDA置为输出脚
; #define 	Set_DS1302_DDRSDA() DDRD|=1<<DS1302_SDA
; //DS1302的SDA置为输入脚
; #define 	Clr_DS1302_DDRSDA() DDRD&=~(1<<DS1302_SDA)
; #define 	DS1302_SEC_Reg 0x80
; #define 	DS1302_MIN_Reg 0x82
; #define 	DS1302_HR_Reg 0x84
; #define 	DS1302_DATE_Reg 0x86
; #define 	DS1302_MONTH_Reg 0x88
; #define 	DS1302_DAY_Reg 0x8a
; #define 	DS1302_YEAR_Reg 0x8c
; #define 	DS1302_CONTROL_Reg 0x8e
; #define 	DS1302_CHARGER_Reg 0x90
; #define 	DS1302_CLKBURST_Reg 0xbe
; //全局变量
; //为了方便,我把个位和十位分开了
; uchar 	year1=0x88;
; uchar 	year0=0x88;
; uchar 	month1=0x88;
; uchar 	month0=0x88;
; uchar 	date0=0x88;
; uchar 	date1=0x88;
; uchar 	day=0x88;
; uchar 	hour1=0x88;
; uchar 	hour0=0x88;
; uchar 	minute1=0x88;
; uchar 	minute0=0x88;
; uchar 	second1=0x88;
; uchar 	second0=0x88;
; void 	DS1302_Init(void);
; uchar 	Check_DS1302(void);
; uchar 	DS1302_Read(uchar reg);
; void 	DS1302_Write(uchar reg,uchar data);
; void 	ReadTime(void);
; //////////////////////////////////////////////
; 
; void port_init(void)
; {
	.dbline 571
;  	 PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 572
;  	 DDRA  = 0xff;//PORTA0-PORTA7 ==> OUTPUT CHAR DATA
	ldi R24,255
	out 0x1a,R24
	.dbline 573
;  	 PORTB = 0x00;
	out 0x18,R2
	.dbline 574
;  	 DDRB  = 0x00;
	out 0x17,R2
	.dbline 575
;  	 PORTC = 0xc3;//PORTC7,PORTC6,PORTC1,PORTC0 ==> key input ,enable_up 
	ldi R24,195
	out 0x15,R24
	.dbline 576
;  	 DDRC  = 0x00;//PC7,PC6,PC1,PC0 ==> PRESS KEY INPUT ; PC2PC3PC4PC5 ==>JTAG USE
	out 0x14,R2
	.dbline 577
;  	 PORTD = 0xf8;//PORTD3-PORTD7 ==> LED CS ,enable_up ; 
	ldi R24,248
	out 0x12,R24
	.dbline 578
;  	 DDRD  = 0xff;//PD3,PD4,PD5,PD6,PD7 ==>LED CS USE ;PD2,PD1,PD0 OUTPUT DS1302 USE
	ldi R24,255
	out 0x11,R24
	.dbline -2
L45:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 583
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 586
; //stop errant interrupts until set up
; //   CLI(); //disable all interrupts
;    	port_init();
	xcall _port_init
	.dbline 587
;    	spi_init(); //初始化SPI接口
	xcall _spi_init
	.dbline 589
; 
;    	MCUCR  = 0x00;
	clr R2
	out 0x35,R2
	.dbline 590
;    	GICR     = 0x00;
	out 0x3b,R2
	.dbline 591
;    	TIMSK    = 0x00; //timer interrupt sources
	out 0x39,R2
	.dbline -2
L46:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e PasswordProcess _PasswordProcess fV
;            val -> R20,R21
	.even
_PasswordProcess::
	xcall push_gset1
	.dbline -1
	.dbline 597
; //   SEI(); //re-enable interrupts
; //all peripherals are now initialized
; }
; 
; void		PasswordProcess(void)
; {
	.dbline 599
; 	int		val;
; 	   	EepromDayDataRd();
	xcall _EepromDayDataRd
	.dbline 600
; 		if(DayData[0]==0)
	lds R2,_DayData
	tst R2
	brne L48
	.dbline 601
; 		{
	.dbline 602
; 	  		Password_alarm=TRUE;
	ldi R24,1
	sts _Password_alarm,R24
	.dbline 603
; 		}
	xjmp L49
L48:
	.dbline 605
; 		else
; 		{
	.dbline 606
; 			ReadTime();
	xcall _ReadTime
	.dbline 607
; 	   		EepromDateValueRd();
	xcall _EepromDateValueRd
	.dbline 609
; //			if((year0==0 && year1==0 &&month1==0 &&month0==1 &&date1==0&&date0==1)||(year0==0xf && year1==0xf &&month1==0x1 &&month0==0xf &&date1==0x3&&date0==0xf))
; 			if((year1==0 && month1==0 && date1==0)||(year1==0xa5 && month1==0x1f && date1==0x3f)) //070616 modify
	lds R2,_year1
	tst R2
	brne L54
	lds R2,_month1
	tst R2
	brne L54
	lds R2,_date1
	tst R2
	breq L52
L54:
	lds R24,_year1
	cpi R24,165
	brne L50
	lds R24,_month1
	cpi R24,31
	brne L50
	lds R24,_date1
	cpi R24,63
	brne L50
L52:
	.dbline 610
; 			{
	.dbline 611
; 		  		Password_alarm=TRUE;
	ldi R24,1
	sts _Password_alarm,R24
	.dbline 612
; 			}

⌨️ 快捷键说明

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