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

📄 soft_test.s

📁 一个关于AVR单片机的例程
💻 S
字号:
	.module soft_test.c
	.area text(rom, con, rel)
	.dbfile E:\avr\2.5.6\soft_test.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 26
; // Test Soft-Uart : See Atmel Applicaton Note 305
; // File: soft_test.c
; // Target : mega16
; // Crystal: 7.3728 Mhz
; // Date 05/30/2007
; // Written/adapted by Dipl.Ing.J.Zastrow
; // for Imagecraft ICCAVR Ver. 6.31
; // Usage : if you need more then one UART
; // Tested with STK500 (Atmel)
; // Customer settings : SEE soft_uart.s
; // 
; 
; #include <iom16v.h>
; #include <macros.h>
; 
; //function prototypes for soft_uart.s
; //one byte return value in R16 !!!
; extern unsigned char getit(void);
; //one byte argument in R16 !!!
; extern putit(register unsigned char key);
; //initialise TxD,RxD port pins
; extern void init_soft_uart(void);
; 
; 
; void port_init(void)
; {
	.dbline 28
;  //default settings all inputs and pull up 
;  PORTA = 0xFF;
	ldi R24,255
	out 0x1b,R24
	.dbline 29
;  DDRA  = 0x00;
	clr R2
	out 0x1a,R2
	.dbline 30
;  PORTB = 0xFF;
	out 0x18,R24
	.dbline 31
;  DDRB  = 0xFF;
	out 0x17,R24
	.dbline 32
;  PORTC = 0xFF;
	out 0x15,R24
	.dbline 33
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 34
;  PORTD = 0xFF;
	out 0x12,R24
	.dbline 35
;  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 40
; }
; 
; //call this routine to initialise all peripherals
; void init_devices(void)
; {
	.dbline 42
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 43
;  port_init();
	xcall _port_init
	.dbline 44
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 45
;  TIMSK = 0x00;
	out 0x39,R2
	.dbline 46
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area lit(rom, con, rel)
L4:
	.byte 'w,'w,'w,46,'a,'v,'r,'v,'i,46,'c,'o,'m,13,10,0
	.area text(rom, con, rel)
	.dbfile E:\avr\2.5.6\soft_test.c
	.dbfunc e main _main fV
;            buf -> y+0
;              s -> R20
;              i -> R22
	.even
_main::
	sbiw R28,16
	.dbline -1
	.dbline 54
;  //all peripherals are now initialised
; }
; 
; //Simply connect RS232 SPARE to
; //PC2 to receive and PC3 to transmitt
;  
; void main(void)
; {
	.dbline 55
;  unsigned char s=0,i=0;
	clr R20
	.dbline 55
	clr R22
	.dbline 56
;  unsigned char buf[]="www.avrvi.com\r\n";
	ldi R24,<L4
	ldi R25,>L4
	movw R30,R28
	ldi R16,16
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 58
;  //defaul
;  init_devices();
	xcall _init_devices
	.dbline 61
;  
;  //do custom settings in soft_uart.s !!!
;  init_soft_uart();
	xcall _init_soft_uart
	.dbline 62
;  for(i=0;i<16;i++)
	xjmp L8
L5:
	.dbline 63
	.dbline 64
	movw R24,R28
	mov R30,R22
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _putit
	.dbline 65
L6:
	.dbline 62
	inc R22
L8:
	.dbline 62
	cpi R22,16
	brlo L5
	xjmp L10
L9:
	.dbline 66
	.dbline 67
	ldi R16,84
	xcall _putit
	.dbline 68
	ldi R16,69
	xcall _putit
	.dbline 69
	ldi R16,83
	xcall _putit
	.dbline 70
	ldi R16,84
	xcall _putit
	.dbline 71
	ldi R16,58
	xcall _putit
	.dbline 72
	xcall _getit
	mov R20,R16
	.dbline 73
	xcall _putit
	.dbline 74
	ldi R16,13
	xcall _putit
	.dbline 75
	ldi R16,10
	xcall _putit
	.dbline 76
L10:
	.dbline 66
	xjmp L9
X0:
	.dbline -2
L3:
	adiw R28,16
	.dbline 0 ; func end
	ret
	.dbsym l buf 0 A[16:16]c
	.dbsym r s 20 c
	.dbsym r i 22 c
	.dbend

⌨️ 快捷键说明

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