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

📄 shiyan.s

📁 已经调试好的AVR单片机MEGA8的串口打印输出程序
💻 S
字号:
	.module shiyan.c
	.area text(rom, con, rel)
	.dbfile C:\icc\examples.avr\chengxu\shiyan\shiyan.c
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 21
; //ICC-AVR application builder : 2007-5-25 21:35:24
; // Target : M8
; // Crystal: 7.3728Mhz
; // 用途:演示getchar(),getchar(),printf()等函数的使用。
; // 作者:XX
; // AVR与虚拟仪器 http://www.avrvi.com
; // 使用7.3728M外部晶振,注意:请短接跳线JP2的1和2,电源跳线连接3.3V或者5V
; // 串口使用JP4的连接方法:1和2短接,使用RS232,请注意查看跳线旁边的示意图
; // 开发板连接:无连线
; 
; #include <iom8v.h>
; #include <macros.h>
; #include <stdio.h>
; 
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
	.dbline 22
; UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 23
; UCSRA = 0x00;
	out 0xb,R2
	.dbline 24
; UCSRC = BIT(URSEL) | 0x06;
	ldi R24,134
	out 0x20,R24
	.dbline 25
; UBRRL = 0x5F; //set baud rate lo
	ldi R24,95
	out 0x9,R24
	.dbline 26
; UBRRH = 0x00; //set baud rate hi
	out 0x20,R2
	.dbline 27
; UCSRB = 0x18;
	ldi R24,24
	out 0xa,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;              i -> R20
	.even
_main::
	.dbline -1
	.dbline 31
; }
; 
; void main(void)
; {
	.dbline 33
; unsigned char i;
; uart0_init();           //初始化串口
	rcall _uart0_init
	.dbline 35
; //printf("[url]www.avrvi.com[/url]\r\n"); //输出字符串
; printf("www.avrvi.com\r\n"); //输出字符串
	ldi R16,<L3
	ldi R17,>L3
	rcall _printf
	rjmp L5
L4:
	.dbline 37
; while(1)
; {
	.dbline 38
; i=getchar();           //读入一个字符
	rcall _getchar
	mov R20,R16
	.dbline 39
; putchar((signed char)i);   //输出字符
	rcall _putchar
	.dbline 40
; if(i=='a') printf("OK\r\n");//如果输入的是a,输出OK,加回车换行。
	cpi R20,97
	brne L7
	.dbline 40
	ldi R16,<L9
	ldi R17,>L9
	rcall _printf
L7:
	.dbline 41
; if(i=='A') printf("GOOD\r\n");//如果输入的是A,输出GOOD,加回车换行。
	cpi R20,65
	brne L10
	.dbline 41
	ldi R16,<L12
	ldi R17,>L12
	rcall _printf
L10:
	.dbline 42
L5:
	.dbline 36
	rjmp L4
X0:
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\icc\examples.avr\chengxu\shiyan\shiyan.c
L12:
	.blkb 7
	.area idata
	.byte 'G,'O,'O,'D,13,10,0
	.area data(ram, con, rel)
	.dbfile C:\icc\examples.avr\chengxu\shiyan\shiyan.c
L9:
	.blkb 5
	.area idata
	.byte 'O,'K,13,10,0
	.area data(ram, con, rel)
	.dbfile C:\icc\examples.avr\chengxu\shiyan\shiyan.c
L3:
	.blkb 16
	.area idata
	.byte 'w,'w,'w,46,'a,'v,'r,'v,'i,46,'c,'o,'m,13,10,0
	.area data(ram, con, rel)
	.dbfile C:\icc\examples.avr\chengxu\shiyan\shiyan.c

⌨️ 快捷键说明

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