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

📄 init.s

📁 avr单片机与flash存储器通信程序,调试通过,希望对大家有所帮助.
💻 S
字号:
	.module init.c
	.area text(rom, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 9
; //ICC-AVR application builder : 2006-4-28 17:54:09
; // Target : M8515
; // Crystal: 11.059Mhz
; 
; #include <iom8515v.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  = 0xBF;
	ldi R24,191
	out 0x17,R24
	.dbline 14
;  PORTC = 0xE0;
	ldi R24,224
	out 0x15,R24
	.dbline 15
;  DDRC  = 0xFC;
	ldi R24,252
	out 0x14,R24
	.dbline 16
;  PORTD = 0x20;
	ldi R24,32
	out 0x12,R24
	.dbline 17
;  DDRD  = 0x22; 
	ldi R24,34
	out 0x11,R24
	.dbline 18
;  PORTE = 0x00;
	out 0x7,R2
	.dbline 19
;  DDRE  = 0x00; 
	out 0x6,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 27
; }
; 
; //TIMER1 initialize - prescale:1
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1mSec
; // actual value:  1.000mSec (0.0%)
; void timer1_init(void)
; {
	.dbline 28
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 29
;  TCNT1H = 0xD4; //setup
	ldi R24,212
	out 0x2d,R24
	.dbline 30
;  TCNT1L = 0xCE;
	ldi R24,206
	out 0x2c,R24
	.dbline 31
;  OCR1AH = 0x2B;
	ldi R24,43
	out 0x2b,R24
	.dbline 32
;  OCR1AL = 0x32;
	ldi R24,50
	out 0x2a,R24
	.dbline 33
;  OCR1BH = 0x2B;
	ldi R24,43
	out 0x29,R24
	.dbline 34
;  OCR1BL = 0x32;
	ldi R24,50
	out 0x28,R24
	.dbline 35
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 36
;  TCCR1B = 0x01; //start Timer
	ldi R24,1
	out 0x2e,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
_count::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
	.dbsym e count _count i
	.area vector(rom, abs)
	.org 12
	rjmp _timer1_ovf_isr
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
	.area text(rom, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R24
	st -y,R25
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 45
; }
; 
; unsigned int count =0;
; extern unsigned char ledflag;
; extern unsigned char shuflag;
; extern unsigned char lcdflag;
; #pragma interrupt_handler timer1_ovf_isr:7
; void timer1_ovf_isr(void)
; {
	.dbline 46
;  TCNT1H = 0xD4; //reload counter high value
	ldi R24,212
	out 0x2d,R24
	.dbline 47
;  TCNT1L = 0xCE; //reload counter low value
	ldi R24,206
	out 0x2c,R24
	.dbline 48
;  if((++count&0xff)==0)ledflag=1;
	lds R24,_count
	lds R25,_count+1
	adiw R24,1
	sts _count+1,R25
	sts _count,R24
	andi R25,0
	cpi R24,0
	cpc R24,R25
	brne L4
X0:
	.dbline 48
	ldi R24,1
	sts _ledflag,R24
L4:
	.dbline 49
;  if((count&0x3ff)==0)shuflag=1;
	lds R24,_count
	lds R25,_count+1
	andi R25,3
	cpi R24,0
	cpc R24,R25
	brne L6
X1:
	.dbline 49
	ldi R24,1
	sts _shuflag,R24
L6:
	.dbline 50
	lds R24,_count
	lds R25,_count+1
	andi R25,1
	cpi R24,0
	cpc R24,R25
	brne L8
X2:
	.dbline 50
	ldi R24,1
	sts _lcdflag,R24
L8:
	.dbline -2
L3:
	ld R24,y+
	out 0x3f,R24
	ld R25,y+
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e spi_init _spi_init fV
	.even
_spi_init::
	.dbline -1
	.dbline 57
;  if((count&0x1ff)==0)lcdflag=1;
;  
; }
; 
; //SPI initialize
; // clock rate: 5529498hz
; void spi_init(void)
; {
	.dbline 58
;  SPCR = 0xFC; //setup SPI
	ldi R24,252
	out 0xd,R24
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 16
	rjmp _spi_stc_isr
	.area text(rom, con, rel)
	.dbfile C:\ATMega8515\测试程序\init.c
	.dbfunc e spi_stc_isr _spi_stc_isr fV
	.even
_spi_stc_isr::
	st -y,R2
	st -y,R24
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 63
; }
; 
; #pragma interrupt_handler spi_stc_isr:9
; void spi_stc_isr(void)
; {
	.dbline 65
;  //byte in SPDR has been sent/received
;  PORTB^=0x10;
	ldi R24,16
	in R2,0x18
	eor R2,R24
	out 0x18,R2
	.dbline 66
;  PORTB^=0x10;
	in R2,0x18
	eor R2,R24
	out 0x18,R2
	.dbline -2
L11:
	ld R2,y+
	out 0x3f,R2
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 73
; }
; 
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; void uart0_init(void)
; {
	.dbline 74
;  UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 75
;  UCSRA = 0x00;
	out 0xb,R2
	.dbline 76
;  UCSRC = BIT(URSEL) | 0x06;
	ldi R24,134
	out 0x20,R24
	.dbline 77
;  UBRRL = 0x47; //set baud rate lo
	ldi R24,71
	out 0x9,R24
	.dbline 78
;  UBRRH = 0x00; //set baud rate hi
	out 0x20,R2
	.dbline 79
;  UCSRB = 0x18;
	ldi R24,24
	out 0xa,R24
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 84
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 86
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 87
;  port_init();
	rcall _port_init
	.dbline 88
;  timer1_init();
	rcall _timer1_init
	.dbline 89
;  spi_init();
	rcall _spi_init
	.dbline 90
;  uart0_init();
	rcall _uart0_init
	.dbline 92
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 93
;  EMCUCR = 0x00;
	out 0x36,R2
	.dbline 94
;  GICR = 0x00;
	out 0x3b,R2
	.dbline 95
;  TIMSK = 0x80;
	ldi R24,128
	out 0x39,R24
	.dbline 96
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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