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

📄 uart0demo.c

📁 飞利浦公司lpc2148串口测试源代码 飞利浦公司lpc2148串口测试源代码
💻 C
字号:
/*============================================================
LPC214X 串口功能演示
作者: Mingtree	ycxms88@163.com   http://www.mcu123.com
==============================================================

本例程的CCLK=60M.
晶振采用12M
倍频系数为:5
分频系数为:2
以上设置在Startup.s中设置
*/

#include <LPC214X.H>
#include <Uart0.H>
#include <Config.H>


#define UART_BAUD(baud) (unsigned  int)((FOSC*PLL_M) / (baud * 16))




 void Init_Uart0(unsigned int Baud)
 {
   /* initialize the serial interface   */
  PINSEL0 = 0x00000005;           /* Enable RxD0 and TxD0                     */
  U0LCR = 0x83;                   /* 8 bits, no Parity, 1 Stop bit            */
  U0DLM=(unsigned char)(Baud>>8);
  U0DLL = (unsigned char)Baud;                     
  
  U0LCR = 0x03;                   /* DLAB = 0     */
 }

void delay (unsigned int i) {                        /* Delay function */
unsigned int n;
while(i>1)
{
	for(n=65535;n>1;n--);
	i--;
}
}

 void main(void)
 {
 Init_Uart0(UART_BAUD(115200));

 while(1)
 {
 Sent_Str("www.mcu123.com \n") ;
 delay(200);
 }
 }

⌨️ 快捷键说明

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