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

📄 main.s

📁 avr单片机atmage16驱动小灯的一些例程 并且包括一些收发数据的程序利用usb口
💻 S
字号:
	.module main.c
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR\project\AVRMEG~2\icc\007-T1-LED\main.c
	.dbfunc e T1_Init _T1_Init fV
	.even
_T1_Init::
	.dbline -1
	.dbline 17
; /*
; 实验七:
; 	定时器T1中断实验。
; 	1、定时器中断实验。定时器产生10mS周期中断,通过计数让PB1电平产生周期变化。
; 	2、内部1 M晶振。
; 	3、进行此实验请插上JP1的所有8个短路块,JP7(LED_EN)短路块。
; 
; 	AVR  mega16学习板
; 	www.iccavr.com
; 	2006-04-03
; */
; 
; #include "iom16v.h"
; #include <macros.h>
; 
; /*初始化定时器,产生10mS周期中断*/
; void T1_Init(void) {
	.dbline 19
; 	
; 	OCR1A = 1250;				/*计数周期为10mS,F=1M*/
	ldi R24,1250
	ldi R25,4
	out 0x2b,R25
	out 0x2a,R24
	.dbline 20
; 	TIMSK |= (1 << OCIE1A);		/*比较中断A允许*/
	in R24,0x39
	ori R24,16
	out 0x39,R24
	.dbline 21
; 	SREG = 0x80;
	ldi R24,128
	out 0x3f,R24
	.dbline 22
; 	TCCR1A = 0x00;
	clr R2
	out 0x2f,R2
	.dbline 23
; 	TCCR1B = 0x08;				/*定时器工作在CTC计数器模式*/
	ldi R24,8
	out 0x2e,R24
	.dbline 24
; 	TCCR1B |= 0x02;				/*设置定时器的分频值为8分频*/
	in R24,0x2e
	ori R24,2
	out 0x2e,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 27
; }
; 
; void main(void) {
	.dbline 29
; 
; 	DDRA = 0x00;				/*方向输入*/
	clr R2
	out 0x1a,R2
	.dbline 30
; 	PORTA = 0xFF;				/*打开上拉*/
	ldi R24,255
	out 0x1b,R24
	.dbline 31
; 	DDRB = 0xFF;				/*方向输出*/
	out 0x17,R24
	.dbline 32
; 	PORTB = 0xFF;				/*电平设置*/
	out 0x18,R24
	.dbline 33
; 	DDRC = 0x00;
	out 0x14,R2
	.dbline 34
; 	PORTC = 0xFF;
	out 0x15,R24
	.dbline 35
; 	DDRD = 0x00;
	out 0x11,R2
	.dbline 36
; 	PORTD = 0xFF;
	out 0x12,R24
	.dbline 38
; 	
; 	T1_Init();
	xcall _T1_Init
	.dbline 39
; 	SEI();						/*中断使能*/
	sei
L3:
	.dbline 41
L4:
	.dbline 41
	xjmp L3
X0:
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 24
	jmp _Int_TCCR1A
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR\project\AVRMEG~2\icc\007-T1-LED\main.c
	.area bss(ram, con, rel)
	.dbfile E:\ICCAVR\project\AVRMEG~2\icc\007-T1-LED\main.c
L7:
	.blkb 1
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR\project\AVRMEG~2\icc\007-T1-LED\main.c
	.dbfunc e Int_TCCR1A _Int_TCCR1A fV
	.dbsym s i L7 c
	.even
_Int_TCCR1A::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 46
; 	
; 	while (1);
; }
; 
; /*定时器T1 TCCR1A组比较匹配中断*/
; #pragma interrupt_handler Int_TCCR1A: 7
; void Int_TCCR1A(void) {
	.dbline 50
; 
; 	static unsigned char i;
; 	
; 	if (i > 20) {
	ldi R24,20
	lds R2,L7
	cp R24,R2
	brsh L8
	.dbline 50
	.dbline 51
; 		PORTB ^= (1 << PB1);
	ldi R24,2
	in R2,0x18
	eor R2,R24
	out 0x18,R2
	.dbline 52
; 		i = 0;
	clr R2
	sts L7,R2
	.dbline 53
; 		}
	xjmp L9
L8:
	.dbline 54
	.dbline 55
	lds R24,L7
	subi R24,255    ; addi 1
	sts L7,R24
	.dbline 56
L9:
	.dbline -2
L6:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend

⌨️ 快捷键说明

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