I am trying to send the data to UART1 in LP2148. Given below is the
code.
But the data displayed is only some junk (mainly ???? is displayed). I
am not able to makeout the problem.
The terminal software is configured at 9600 baud. pclk is 15 MHz.
Here is the code:
#include <lpc214x.h> //Includes LPC2148 register definitions
#define Fosc 12000000
#define Fcclk (Fosc * 5)
#define Fcco (Fcclk * 4)
#define Fpclk (Fcclk / 4)
#define UART_BPS 9600 //Set Baud Rate here
const unsigned char SEND_STRING[] = "Hello. This is a test programnSend
any character from terminal to continuen";
const unsigned char SEND_STRING1[] = "Test Passedn";
void Init_UART1(void) //This function setups UART1
{
unsigned int Baud16;
U1LCR = 0x83; // DLAB = 1
Baud16 = (Fpclk / 16) / UART_BPS;
U1DLM = Baud16 / 256;
U1DLL = Baud16 % 256;
U1LCR = 0x03;
}
void UART1_SendByte(unsigned char data) //A function to send a byte on
UART1
{
U1THR = data;
while( (U1LSR&0x40)==0 );
}
void UART1_SendStr(const unsigned char *str) //A function to send a
string on UART1
{
while(1)
{
if( *str == '
UART1_SendByte(*str++);
}
}
int main(void)
{
PINSEL0 = 0x00050000; // Enable UART1 Rx and Tx pins
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
Init_UART1();
UART1_SendStr(SEND_STRING);
while((U1LSR&0x01)==0);
UART1_SendStr(SEND_STRING1);
while(1)
{
}
// return(0);
}
---------------------------------------
Posted through http://www.EmbeddedRelated.com