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

📄 usart.s

📁 单片机应用 1.1602LCD 2.2004LCD源码 3.ATmega16 PWM源码 4.ATmega8 LED源码 5.无线影音Nrf2401源码 6.AVR串口源码
💻 S
字号:
	.module USART.C
	.area text(rom, con, rel)
	.dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 5
; #include <iom32v.h>
; #include <macros.h>
; #include <stdio.h>
; void port_init(void)
; {
	.dbline 6
;  PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 7
;  DDRA  = 0x00;
	out 0x1a,R2
	.dbline 8
;  PORTB = 0x00;
	out 0x18,R2
	.dbline 9
;  DDRB  = 0x00;
	out 0x17,R2
	.dbline 10
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 11
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 12
;  PORTD = 0x02;
	ldi R24,2
	out 0x12,R24
	.dbline 13
;  DDRD  = 0xff;
	ldi R24,255
	out 0x11,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 22
; }
; 
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9615 (0.2%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
	.dbline 23
;  UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 24
;  UCSRA = 0x00;
	out 0xb,R2
	.dbline 25
;  UCSRC = BIT(URSEL) | 0x06;
	ldi R24,134
	out 0x20,R24
	.dbline 26
;  UBRRL = 0x2F; //set baud rate lo
	ldi R24,47
	out 0x9,R24
	.dbline 27
;  UBRRH = 0x00; //set baud rate hi
	out 0x20,R2
	.dbline 28
;  UCSRB = 0x18;
	ldi R24,24
	out 0xa,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 33
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 35
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 36
;  port_init();
	xcall _port_init
	.dbline 37
;  uart0_init();
	xcall _uart0_init
	.dbline 39
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 40
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 41
;  TIMSK = 0x00; //timer interrupt sources
	out 0x39,R2
	.dbline 42
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Puts _Puts fV
;              s -> R20,R21
	.even
_Puts::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 46
;  //all peripherals are now initialized
; }
; void Puts( unsigned char *s) // \arg pointer to a string ending by \0
; {
	xjmp L6
L5:
	.dbline 49
	.dbline 50
	movw R30,R20
	ldd R16,z+0
	xcall _putchar
	.dbline 51
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 52
L6:
	.dbline 48
;   
; 	 while (*s) 
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L5
	.dbline -2
L4:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r s 20 pc
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 56
;       {
; 	 putchar(*s);
; 	 s++;
;       }
; }
; 
; void main(void)
; {
	.dbline 57
;  init_devices();
	xcall _init_devices
	xjmp L10
L9:
	.dbline 59
	.dbline 60
	ldi R16,<L12
	ldi R17,>L12
	xcall _puts
	.dbline 61
L10:
	.dbline 58
	xjmp L9
X0:
	.dbline -2
L8:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C
L12:
	.blkb 34
	.area idata
	.byte 'W,'W,'W,46,'O,'U,'R,'A,'V,'R,46,'C,'O,'M,32,'M
	.byte 'Y,32,'N,'A,'M,'E,32,'I,'S,32,'P,'A,'S,'Y,'O,'N
	.byte 'G,0
	.area data(ram, con, rel)
	.dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C

⌨️ 快捷键说明

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