uart.c

来自「BF533的程序」· C语言 代码 · 共 44 行

C
44
字号
/******************************************************************************/
//
// Name: 	BF532-based EZ-KIT UART Setup
//
/******************************************************************************


Purpose:		The file sets up the UART port for serial port transfers.
				The Baud rate is setup at 115.2kbps
				where Baud rate = SCLK/(16*Divisor) and SCLK = 75.6 MHz
				

*********************************************************************************/


#include <cdefBF533.h>

void Init_UART(void)
{
/*****************************************************************************
 *  First of all, enable UART clock. 
 ****************************************************************************/ 
	*pUART_GCTL |= UCEN;
	
	*pUART_LCR |= DLAB;		//	Reset the UART and enable access to DLL
	
	*pUART_DLL = 0x0029;	//	Set the Baud rate to be 115.2kbps
//	*pUART_DLL = 0x0052;	//	Set the Baud rate to be 57.6kbps
	*pUART_DLH = 0;
	
	*pUART_LCR = 0x0003;	//	8-bit, no parity, 1 STOP bit	
	
}

void UART_PUTC(char TXD)
{
	//	Make sure the Transmit Hold Reg is empty first
	while ((*pUART_LSR & 0x0020) == 0);
	*pUART_THR = (unsigned short) TXD;
}

	

⌨️ 快捷键说明

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