Hello, I have some problems with my LPC2132, when I try to use uart 0/1, I only get garbage.
My code:
#define TEMP (1<<6)
#define DEMP (1<<0)
void PLL_config()
{
VICIntEnable=0x0; // Disable all interrups
PLLFEED = 0xAA;
PLLFEED = 0x55;
PLLCON = 0x00; // Disable PLL
PLLFEED = 0xAA;
PLLFEED = 0x55;
VPBDIV=0x00; // Pclk=fosc/4
}
void serie0_config()
{
U0FCR=7; // Clean & active FIFO
U0FDR=0x10;
U0LCR=0x83; // Dlab=1 & 8 bits data
U0DLL=0x60; // using 14,7465MHz crystal => PLL off => Pclk=fosc/4 => 2400 Bps => Divisor Latch= 96 => 0x0060
U0DLM=0x00;
U0LCR=0x03; // Dlab=0
U0IER=0; // uart0 interrupt disable;
}
int main(void)
{
unsigned char flag=0;
PLL_config();
PINSEL0=5; // P0.0= TXD0 y P0.1= RXD0
PINSEL1=0;
serie0_config();
U0THR='a';
while(1)
{
if(U0LSR&DEMP)
{
if(U0RBR) { } // Clean U0RBR
if(flag==1)
flag=0;
else
{flag=1; U0THR='a';}
}
if((U0LSR&TEMP)&&flag)
U0THR='a';
}
}
Using Keil simulation, everything is ok, using proteus too.
When I flash LPC using LPC2000 v2.2.3, everything is fine, but using hyperterminal my tx data and rx data is wrong, I get โรกโ โ 0xC1.
Any idea? Thxs.