This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCB2140 Serial Communication via RS232

I am new to MCB2140. I want to interface RS232 to MCB140 for serial communication between PC and Board. Below is my code. I searched for manual and gone through the basics for UART initialization. Everything here I did is correct in my knowledge. But I cant receive anything to hyperterminal.What will be the problem??

#include <LPC21xx.H>
//Function declaration
void init_serial (void);
char SendChar (char SDat);
void SendDigit(unsigned int dat);
void SendString(char *lcd_string);

int main(void)
{
//int j=0;
init_serial (); // initialise serial port with 9600bps
SendChar ('A'); // transmit char A
SendChar ('\n'); // transmit new line character
SendString("My first program"); // transmit string
SendChar ('\n'); // transmit new line character
SendDigit(236); // transmit digit 236
}

//Function Definitions
void init_serial (void)
  {                           /*Initialize Serial Interface  */
  PINSEL0 = PINSEL0 | 0X00000005;     /* Enable RxD0 and TxD0              */
  U0LCR = 0X83;                       /*8 bits, no Parity, 1 Stop bit      */
  U0DLL = 98;                        /* 9600bps baud rate */
  U0LCR = 0X03;                     /* DLAB = 0                      */
  }
int GetChar (void)  //for later use
{                                 /* Read character from Serial Port   */
  while (!(U0LSR & 0x01));
  return (U0RBR);
}
char SendChar (char SDat)
  {                                /* Write character to Serial Port    */
while (!(U0LSR & 0x20));
return (U0THR = SDat);
}
void SendString(char *lcd_string)
{
while (*lcd_string)
{
SendChar(*lcd_string++);
}
}
void SendDigit(unsigned int dat)
{
unsigned int temp,i=0, buf[10];
while(dat>=10)
{
buf[i]=dat%10;
dat=dat/10;
i++;
}
buf[i]=dat;
for(temp=0;temp<=i;temp++)
{
SendChar(buf[i-temp]+'0');
}
}