LPC2106 UART0
2004-10-17 by mike robins
I purchased an LPC2106 board from olimex with a 14.7456 MHz crystal.
I'm having a very difficult time getting the serial port to work and output to the screen.
I'm trying to transmit at 57600,8,1,n.
The mcu osc is set up for 4 times the crystal.
I programmed the board with a precompiled uart program that echos characters back, and it worked fine, so the connections are good and the uc works.
Here is the code:
#include <C:\GNUARM\bin\lpc210x.h>
int main(void);
void Init(void);
void Delay (unsigned long a);
int main(void)
{
Init(); //Initialize clock
IODIR=0x000000080; //P0.7 is output(LED)
//Setup UART
PCONP &= 0x08;
UART0_IER = 0x00;
UART0_LCR = 0x80;
UART0_DLL = 0x20;
UART0_DLM = 0x00;
UART0_LCR = 0x03;
UART0_FCR = 0x07;
while (1)
{
// flash LED
IOCLR |= 0x00000080; //LED on
Delay(100000);
IOSET |= 0x00000080; //LED off
Delay(100000);
// Transmit Hi
while((UART0_LSR & 0x40) == 0){}
UART0_THR = 'H';
while((UART0_LSR & 0x40) == 0){}
UART0_THR = 'i';
}
}
void Init(void)
{
// Init PLL
PLLCFG=0x23; // P=2, M=4, PLLfreq = 235,9296 Mhz, CCLK = 58,9824 Mhz
PLLFEED=0xAA; // 14.7456MHz
PLLFEED=0x55;
PLLCON=0x01; // Enable the PLL
PLLFEED=0xAA;
PLLFEED=0x55;
while(!(PLLSTAT & 0x0400)){} // Wait for PLL to lock
PLLCON=0x03; // Connect PLL as clock source
PLLFEED=0xAA;
PLLFEED=0x55;
//Init MAM & Flash memory fetch
MAMTIM=0x07;
MAMCR=0x00;
MAMMAP=0x01;
VPBDIV=0x01; //pclk = cclk
}
void Delay (unsigned long a)
{
while (--a!=0){}
}
The code flashes the LED but "Hi" is not sent???
Any help would be greatly appreciated.
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
[Non-text portions of this message have been removed]