#include<stdio.h>
#include<lpc23xx.h>
#define baudrate 115200
#define Fpclk 60000000/4
void Init_uart()
{
unsigned long Fdiv;
PINSEL0 &= ~((1<<5)|(1<<7)); /* RxD0 and TxD0 */
PINSEL0 |= (1<<6)|(1<<4); /* RxD0 and TxD0 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
Fdiv = ( Fpclk / 16 ) / baudrate ; /*baud rate */
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03; /* DLAB = 0 */
U0FCR = 0x07; /* Enable and reset TX and RX FIFO. */
}
void UARTSend_String( unsigned long portNum, unsigned char *BufferPtr)
{
while ( *BufferPtr!='\0')
{
U0THR = *BufferPtr;
while((U0LSR&0x40)==0);
BufferPtr++;
}
}
int main()
{
Init_uart();
while(1)
{
UARTSend_String(0,"hello");
}
}
便宜没有错误,就是收不到,帮忙看看是什么问题吧,谢谢! |