#include <LPC21xx.H>
void init_serial (void);
int putchar(int ch);
int getchar (void);
int main(void)
{
VPBDIV = 0x02; // Divide Pclk by two
init_serial();
while(1)
{
putchar(getchar()+1); // Echo terminal
}
}
void init_serial (void)
{
PINSEL0 = 0x00000005; // Enable RxD0 and TxD0
U0LCR = 0x00000083; //8 bits, no Parity, 1 Stop bit
U0DLL = 0x000000C3; //9600 Baud Rate @ 30MHz VPB Clock
U0LCR = 0x00000003;
}
int putchar (int ch)
{
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
int getchar (void)
{
while (!(U0LSR & 0x01));
return (U0RBR);
}
void init_serial (void);
int putchar(int ch);
int getchar (void);
int main(void)
{
VPBDIV = 0x02; // Divide Pclk by two
init_serial();
while(1)
{
putchar(getchar()+1); // Echo terminal
}
}
void init_serial (void)
{
PINSEL0 = 0x00000005; // Enable RxD0 and TxD0
U0LCR = 0x00000083; //8 bits, no Parity, 1 Stop bit
U0DLL = 0x000000C3; //9600 Baud Rate @ 30MHz VPB Clock
U0LCR = 0x00000003;
}
int putchar (int ch)
{
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
int getchar (void)
{
while (!(U0LSR & 0x01));
return (U0RBR);
}
Comments
Post a Comment