Вы находитесь на странице: 1из 2

#include <LPC214x.

H>

/* LPC214x definitions */

typedef unsigned char uc;


#define RDR
#define THRE

0x01
0x20

void uart0_init()
{
/* initialize the serial interface
*/
PINSEL0 = 0x00000005;
/* Enable RxD0 and TxD0
U0LCR = 0x83;
/* 8 bits, no Parity, 1 Stop bit
U0DLL = 97;
/* 9600 Baud Rate @ 15MHz VPB Clock

*/
*/
U0DLL = 194 for 30MHz and
U0DLM= 0x01; U0DLL = 0x84;

at VBP + 60MHz
U0LCR = 0x03;
}

*/
/* DLAB = 0

*/

uc get_char()
{
while (!(U0LSR & RDR));
return (U0RBR);
}
void put_char(uc dt)
{
while(!(U0LSR & THRE)); // Wait until UART0 ready to send character
U0THR = dt; // Send character
}
void puts(uc *st)
{
while(*st)
{
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

put_char(*st++);
}
}
int main (void)
{
uart0_init();
puts("UART0 echo test [press any key]");
while (1)
{
put_char(get_char());
}
}

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Вам также может понравиться