单片机开发资料光盘-双龙-686M.zip

源代码在线查看: uart.s

软件大小: 574027 K
上传用户: rllfllef
关键词: 686 zip 单片机 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module uart.c
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
					.dbfunc e putchar _putchar fV
				;              c -> R16
					.even
				_putchar::
					.dbline -1
					.dbline 20
				; /******************************************/
				; /*           广州天河双龙电子公司         */
				; /*           http://www.sl.com.cn         */ 
				; /*              RS232通信演示程序         */ 
				; /*             作者:ntzwq@wx88.net        */
				; /*               2002年5月10日            */
				; /*  目标MCU:MEGA8   晶振:外部(EXT) 8MHZ   */
				; /******************************************/
				; //  1、使用ICCAVR的终端调试窗口(Terminal),进行通信调试。
				; //  2、对ICCAVR的终端调试窗口进行设置,设置串口为com1或com2,
				; //     通信波特率为19200(Tools->Environment Options...)。
				; //  3、将PC屏幕光标定位于调试窗口中。
				; #include 
				; #define fosc 8000000 //晶振8MHZ
				; #define baud 19200	 //波特率
				; #define osc_address   0x1ff0
				; extern unsigned char read_flash(unsigned int add);
				; /*  		字符输出函数 		 */
				; void putchar(unsigned char c)
				; 	{	 
				L2:
					.dbline 21
				L3:
					.dbline 21
				;      while (!(UCSRA&(1					sbis 0xb,5
					rjmp L2
					.dbline 22
				; 	 UDR=c;    
					out 0xc,R16
					.dbline -2
					.dbline 23
				; 	}
				L1:
					.dbline 0 ; func end
					ret
					.dbsym r c 16 c
					.dbend
					.dbfunc e getchar _getchar fc
					.even
				_getchar::
					.dbline -1
					.dbline 26
				; /*  		字符输入函数 		 */	
				; unsigned char getchar(void)
				;   	{
				L6:
					.dbline 27
				L7:
					.dbline 27
				; 	 while(!(UCSRA& (1					sbis 0xb,7
					rjmp L6
					.dbline 28
				;      return UDR;
					in R16,0xc
					.dbline -2
				L5:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e puts _puts fI
				;              s -> R20,R21
					.even
				_puts::
					rcall push_gset1
					movw R20,R16
					.dbline -1
					.dbline 32
				; 	}		
				; /*			字符串输出函数	   	 */	
				; int puts(char *s)
				; 	{
					rjmp L11
				L10:
					.dbline 34
					.dbline 35
					movw R30,R20
					ldd R16,z+0
					rcall _putchar
					.dbline 36
					subi R20,255  ; offset = 1
					sbci R21,255
					.dbline 37
				L11:
					.dbline 33
				; 	while (*s)
					movw R30,R20
					ldd R2,z+0
					tst R2
					brne L10
					.dbline 38
				; 		{
				; 		putchar(*s);
				; 		s++;
				; 		}	
				;     putchar(0x0a);//回车换行
					ldi R16,10
					rcall _putchar
					.dbline 39
				; 	putchar(0x0d);
					ldi R16,13
					rcall _putchar
					.dbline 40
				; 	return 1;
					ldi R16,1
					ldi R17,0
					.dbline -2
				L9:
					rcall pop_gset1
					.dbline 0 ; func end
					ret
					.dbsym r s 20 pc
					.dbend
					.dbfunc e putstr _putstr fV
				;              s -> R20,R21
					.even
				_putstr::
					rcall push_gset1
					movw R20,R16
					.dbline -1
					.dbline 44
				; 	}
				; /*	 	   不含回车换行的字符串输出函数 	 */	
				; void putstr(char *s)
				; 	{
					rjmp L15
				L14:
					.dbline 46
					.dbline 47
					movw R30,R20
					ldd R16,z+0
					rcall _putchar
					.dbline 48
					subi R20,255  ; offset = 1
					sbci R21,255
					.dbline 49
				L15:
					.dbline 45
				; 	while (*s)
					movw R30,R20
					ldd R2,z+0
					tst R2
					brne L14
					.dbline -2
					.dbline 50
				; 		{
				; 		putchar(*s);
				; 		s++;
				; 		}	
				; 	}	
				L13:
					rcall pop_gset1
					.dbline 0 ; func end
					ret
					.dbsym r s 20 pc
					.dbend
					.dbfunc e uart_init _uart_init fV
					.even
				_uart_init::
					.dbline -1
					.dbline 53
				; /*			UART初始化				*/	
				; void uart_init(void)
				; {
					.dbline 54
				;  OSCCAL=read_flash(osc_address);
					ldi R16,8176
					ldi R17,31
					rcall _read_flash
					out 0x31,R16
					.dbline 55
				;  UCSRB=(1					ldi R24,24
					out 0xa,R24
					.dbline 56
				;  UBRRL=(fosc/16/(baud+1))%256;
					ldi R24,26
					out 0x9,R24
					.dbline 57
				;  UBRRH=(fosc/16/(baud+1))/256;
					clr R2
					out 0x20,R2
					.dbline 58
				;  UCSRC=(1					ldi R24,134
					out 0x20,R24
					.dbline -2
					.dbline 59
				; }
				L17:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e main _main fV
				;              i -> R20
					.even
				_main::
					.dbline -1
					.dbline 62
				; /*			RS232通信main函数		*/
				; void main(void)
				; {
					.dbline 64
				;  unsigned char i;
				;  uart_init();
					rcall _uart_init
					.dbline 65
				;  puts("广州天河双龙电子公司RS232通信演示程序");
					ldi R16,					ldi R17,>L19
					rcall _puts
					.dbline 66
				;  puts("HTTP://WWW.SL.COM.CN");
					ldi R16,					ldi R17,>L20
					rcall _puts
					.dbline 67
				;  puts("MAIL TO:sllg@sl.com.cn");
					ldi R16,					ldi R17,>L21
					rcall _puts
					rjmp L23
				L22:
					.dbline 69
				;  while(1)
				;     {
					.dbline 70
				; 	 i=getchar();
					rcall _getchar
					mov R20,R16
					.dbline 71
				; 	 if (i!=0)//按PC键盘开始测试
					tst R16
					breq L25
					.dbline 72
				; 	   {
					.dbline 73
				; 	    putstr("当前按键是:");
					ldi R16,					ldi R17,>L27
					rcall _putstr
					.dbline 74
				; 		putchar(i);
					mov R16,R20
					rcall _putchar
					.dbline 75
				; 		putchar(0x0a);
					ldi R16,10
					rcall _putchar
					.dbline 76
				; 		putchar(0x0d);
					ldi R16,13
					rcall _putchar
					.dbline 77
				; 	    puts("广州天河双龙电子公司RS232通信演示程序");
					ldi R16,					ldi R17,>L19
					rcall _puts
					.dbline 78
				;  		puts("HTTP://WWW.SL.COM.CN");
					ldi R16,					ldi R17,>L20
					rcall _puts
					.dbline 79
				;   		puts("MAIL TO:sllg@sl.com.cn");
					ldi R16,					ldi R17,>L21
					rcall _puts
					.dbline 80
				; 		putchar(0x0a);
					ldi R16,10
					rcall _putchar
					.dbline 81
				; 		putchar(0x0d); 
					ldi R16,13
					rcall _putchar
					.dbline 82
				; 	   }	 
				L25:
					.dbline 83
				L23:
					.dbline 68
					rjmp L22
				X0:
					.dbline -2
					.dbline 84
				; 	}
				; }
				L18:
					.dbline 0 ; func end
					ret
					.dbsym r i 20 c
					.dbend
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
				L27:
					.blkb 13
					.area idata
					.byte 181,177,199,176,176,180,188,252,202,199,163,186,0
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
				L21:
					.blkb 23
					.area idata
					.byte 'M,'A,'I,'L,32,'T,'O,58,'s,'l,'l,'g,64,'s,'l,46
					.byte 'c,'o,'m,46,'c,'n,0
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
				L20:
					.blkb 21
					.area idata
					.byte 'H,'T,'T,'P,58,47,47,'W,'W,'W,46,'S,'L,46,'C,'O
					.byte 'M,46,'C,'N,0
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
				L19:
					.blkb 38
					.area idata
					.byte 185,227,214,221,204,236,186,211,203,171,193,250,181,231,215,211
					.byte 185,171,203,190,'R,'S,50,51,50,205,168,208,197,209,221,202
					.byte 190,179,204,208,242,0
					.area data(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\uart\uart.c
							

相关资源