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

📄 main.s

📁 GCC-AVR application builder : 2007-8-31 18:00:11 Target : M16 Crystal: 7.3728Mhz 作者:小马哈 功能:SP
💻 S
字号:
	.module main.c
	.area text(rom, con, rel)
	.dbfile C:\TEMP\m16spi\main.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 16
; //ICC-AVR application builder : 2008-6-16 18:47:52
; // Target : M16
; // Crystal: 16.000Mhz
; 
; #define MASTER
; #include <iom16v.h>
; #include <macros.h>
; #include "delay.h"
; 
; #ifdef MASTER
; 	#warning "build as MASTER SPI"
; #else
; 	#warning "build as SLAVE SPI"
; #endif
; void port_init(void)
; {
	.dbline 17
;  	PORTA = 0xff;
	ldi R24,255
	out 0x1b,R24
	.dbline 18
;  	DDRA  = 0xff;
	out 0x1a,R24
	.dbline 19
;  	PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 20
;  	DDRB  = 0x00;
	out 0x17,R2
	.dbline 21
;  	PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 22
;  	DDRC  = 0x00;
	out 0x14,R2
	.dbline 23
;  	PORTD = 0x00;
	out 0x12,R2
	.dbline 24
;  	DDRD  = 0x00;
	out 0x11,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e spi_init _spi_init fV
	.even
_spi_init::
	.dbline -1
	.dbline 30
; }
; 
; //SPI initialize
; // clock rate: 1000000hz
; void spi_init(void)
; {
	.dbline 32
; 	#ifdef MASTER
;  		SPCR = 0x51; //setup SPI Master
	ldi R24,81
	out 0xd,R24
	.dbline 36
; 	#else
;  		SPCR = 0x41|0x80; //setup SPI Slave
; 	#endif
;  	SPSR = 0x00; //setup SPI
	clr R2
	out 0xe,R2
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 41
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 43
;  	//stop errant interrupts until set up
;  	CLI(); //disable all interrupts
	cli
	.dbline 44
;  	port_init();
	xcall _port_init
	.dbline 45
;  	spi_init();
	xcall _spi_init
	.dbline 47
; 
;  	MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 48
;  	GICR  = 0x00;
	out 0x3b,R2
	.dbline 49
;  	TIMSK = 0x00; //timer interrupt sources
	out 0x39,R2
	.dbline 50
;  	SEI(); //re-enable interrupts
	sei
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 68
	jmp _SPI_RXC_ISR
	.area text(rom, con, rel)
	.dbfile C:\TEMP\m16spi\main.c
	.dbfunc e SPI_RXC_ISR _SPI_RXC_ISR fV
	.even
_SPI_RXC_ISR::
	.dbline -1
	.dbline 56
;  	//all peripherals are now initialized
; }
; 
; #pragma interrupt_handler SPI_RXC_ISR:18 
; void SPI_RXC_ISR(void) 
; { 
	.dbline -2
L4:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e main _main fV
;              n -> R20
	.even
_main::
	.dbline -1
	.dbline 67
;   	//unsigned char data_temp; 
;   	//SPDR=0xab; 
;   	//data_temp=SPDR; 
; 	#ifdef MASTER
; 	#else
; 		PORTA=SPDR;
; 	#endif
; } 
; //
; void main(void)
; {
	.dbline 68
; 	unsigned char n=0;
	clr R20
	.dbline 69
;  	init_devices();
	xcall _init_devices
	.dbline 72
;  	//insert your functional code here...
; 	#ifdef MASTER
; 		DDRB|=0x10;
	sbi 0x17,4
	.dbline 73
; 		PORTB|=0x10;
	sbi 0x18,4
	xjmp L7
L6:
	.dbline 78
; 	#else
; 		PORTB|=0x10;
; 	#endif
; 	while(1)
; 	{
	.dbline 79
; 		n++;
	inc R20
	.dbline 81
; 		#ifdef MASTER
; 			PORTB&=0xef;
	in R24,0x18
	andi R24,239
	out 0x18,R24
	.dbline 82
; 			SPDR=n;
	out 0xf,R20
L9:
	.dbline 86
L10:
	.dbline 86
	sbis 0xe,7
	rjmp L9
	.dbline 87
	sbi 0x18,4
	.dbline 91
	ldi R16,200
	ldi R17,0
	xcall _delay_nms
	.dbline 92
L7:
	.dbline 77
	xjmp L6
X0:
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbsym r n 20 c
	.dbend

⌨️ 快捷键说明

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