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

📄 uart.s

📁 avr单片机atmage16驱动小灯的一些例程 并且包括一些收发数据的程序利用usb口
💻 S
字号:
	.module uart.c
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR\project\AVRMEG~2\icc\019-TEST\uart.c
	.dbfunc e Uart_Init _Uart_Init fV
	.even
_Uart_Init::
	.dbline -1
	.dbline 4
; #include "iom16v.h"
; 
; /*串口初始化函数*/
; void Uart_Init(void) {
	.dbline 5
; 	UCSRA = 0x02;		/*倍速*/
	ldi R24,2
	out 0xb,R24
	.dbline 6
; 	UCSRB = 0x18;		/*允许接收和发送*/
	ldi R24,24
	out 0xa,R24
	.dbline 7
; 	UCSRC = 0x06;		/*8位数据*/
	ldi R24,6
	out 0x20,R24
	.dbline 8
; 	UBRRH = 0x00;
	clr R2
	out 0x20,R2
	.dbline 9
; 	UBRRL = 12;		/*9600*/
	ldi R24,12
	out 0x9,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Uart_Transmit _Uart_Transmit fV
;              i -> R16
	.even
_Uart_Transmit::
	.dbline -1
	.dbline 13
; }
; 
; /*数据发送,查询方式*/
; void Uart_Transmit(unsigned char i) {
L3:
	.dbline 15
L4:
	.dbline 15
; 
; 	while (!(UCSRA & (1<<UDRE)));		/* 等待发送缓冲器为空*/
	sbis 0xb,5
	rjmp L3
	.dbline 16
; 	UDR = i;				/* 发送数据*/
	out 0xc,R16
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Uart_Receive _Uart_Receive fc
	.even
_Uart_Receive::
	.dbline -1
	.dbline 20
; }
; 
; /*数据接收,查询方式*/
; unsigned char Uart_Receive( void ) {
L7:
	.dbline 22
L8:
	.dbline 22
; 
; 	while (!(UCSRA & (1<<RXC)));		/* 等待接收数据*/
	sbis 0xb,7
	rjmp L7
	.dbline 23
; 	return UDR;				/* 获取并返回数据*/
	in R16,0xc
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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