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

📄 mega16.s

📁 AVR 初学者
💻 S
字号:
	.module mega16.c
	.area text(rom, con, rel)
	.dbfile E:\单片机\单片机程序\AVR程序\闪烁灯\mega16.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 9
; //ICC-AVR application builder : 2008-8-1 15:39:15
; // Target : M16
; // Crystal: 16.000Mhz
; 
; #include <iom16v.h>
; #include <macros.h>
; 
; void port_init(void)
; {
	.dbline 10
;  PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 11
;  DDRA  = 0xFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 12
;  PORTB = 0x00;
	out 0x18,R2
	.dbline 13
;  DDRB  = 0x00;
	out 0x17,R2
	.dbline 14
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 15
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 16
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 17
;  DDRD  = 0x00;
	out 0x11,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 22
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 24
;  //stop errant interrupts until set up0
;  CLI(); //disable all interrupts
	cli
	.dbline 25
;  port_init();
	xcall _port_init
	.dbline 27
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 28
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 29
;  TIMSK = 0x00; //timer interrupt sources
	out 0x39,R2
	.dbline 30
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;              i -> R20,R21
;              j -> R22,R23
	.even
_main::
	.dbline -1
	.dbline 35
;  //all peripherals are now initialized
; }
; 
; void main()
; {
	.dbline 37
;   unsigned int i,j;
;   init_devices();
	xcall _init_devices
	.dbline 38
;   PORTA = 0XAA;
	ldi R24,170
	out 0x1b,R24
	xjmp L5
L4:
	.dbline 40
;   while(1)
;   {
	.dbline 41
;     for(i=0;i<1000;i++)
	clr R20
	clr R21
	xjmp L10
L7:
	.dbline 42
	clr R22
	clr R23
	xjmp L14
L11:
	.dbline 42
L12:
	.dbline 42
	subi R22,255  ; offset = 1
	sbci R23,255
L14:
	.dbline 42
	cpi R22,232
	ldi R30,3
	cpc R23,R30
	brlo L11
L8:
	.dbline 41
	subi R20,255  ; offset = 1
	sbci R21,255
L10:
	.dbline 41
	cpi R20,232
	ldi R30,3
	cpc R21,R30
	brlo L7
	.dbline 43
	in R2,0x1b
	com R2
	out 0x1b,R2
	.dbline 44
L5:
	.dbline 39
	xjmp L4
X0:
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r j 22 i
	.dbend

⌨️ 快捷键说明

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