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

📄 uart.c

📁 我写的C8051F02x的一部分模块库
💻 C
字号:
/*------------------------------------------------------------
	File Name: 		uart.c
	Auther:			Samuel
	Revision:		R1
	History:		R1			Jul.05, 2007		Creation
------------------------------------------------------------*/

#include "common.h"
#include "uart.h"


void Uart_Init(void)
{
	
	//UART0, mode:1, baud:115200(22.1184MHz), 8bit

	XBR0 = Reg_Field_Set(XBR0, BIT2);	// UART0 routed to pins P0.0 and P0.1;
	XBR2 = Reg_Field_Set(XBR2, BIT6);	// 交叉开关使能

	PCON |= 0x80;						// SMOD=1 (HW_UART uses Timer 1 overflow
										// with no divide down).

	TMOD = 0x20;						// Configure Timer 1 for use by HW_UART
	CKCON |= 0x10;						// Timer 1 derived from SYSCLK
	TH1 = 0xF4;							// Timer 1 initial value
	TL1 = 0xF4;							// Timer 1 reload value

	TR1 = 1;    						// Start Timer 1

	RI=0;								// Clear HW_UART receive and transmit
	TI=0;								// complete indicators.

	SCON = 0x50;						// Configure HW_UART for mode 1, receiver enabled.

    SBUF=0x00;							// NULL: make the first TI=1


}

⌨️ 快捷键说明

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