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

LPC2129 UART Problem

Hello,

im using a board with LPC2139 with JTAG, it has 2 UARTs however wenever i try and flash a simple UART program of, say, transmitting a string or echoing a character on it, it does not work.

the code is given below,

#include <LPC21xx.H>                     /* LPC21xx definitions               */

#define CR     0x0D


void initserial (void)  {                /* Initialize Serial Interface       */
  VPBDIV=0x02;                           /* PCLK=CCLK/2                        */
  PINSEL0 = 0x00050000;                  /* Enable RxD1 and TxD1              */
  U1LCR = 0x83;                          /* 8 bits, no Parity, 1 Stop bit     */
  U1DLL = 27;                            /* 9600 Baud Rate @ 12MHz VPB Clock  */
  U1LCR = 0x03;                          /* DLAB = 0                          */
}


int sendchar (int ch)  {                 /* Write character to Serial Port    */

  while (!(U1LSR & 0x20));
  return (U1THR = ch);
}


int getkey (void)  {                     /* Read character from Serial Port   */

  while (!(U1LSR & 0x01));

  return (U1RBR);
}
int main()
{
        initserial();
        while(1)
        {
                sendchar(getkey());
        }
}

im gettin the following problems:
1. wen i type in characters at the terminal in my computer, garbage values are echoed only(baud rate???)
2. the terminal does not accept my keystrokes very smoothly, the echoing of garbage values is very sporadic
3. the program is written for uart1, for uart0 the program does not work at all and yes, i do change the PSEN and all other relevant values to use uart0 instead of uart1. besides, in uart 1, the garbage values are somewhat regular, but still, garbage
4. even if i dont burn the program, uart0 connected to the terminal still echoes garbage values, is this normal? uart1 does the same thing, echoes garbage sporadically.

and here are the things ive tried to resolve the problems:
1. i tried all possible combinations of baud rates
2. used the PLL too to increase the value of cclck, but to no avail
3. tried numerous examples given in keil and online, same problem, same issue
4. tried sending AT commands through a GSM modem to call my mobile phone, just to check if at all something wwas echoed, failed, time and again.

is it possible that the uarts or for that matter, the board is damaged in any way??? the program is flashed perfectly and the programs i flash are all simulated on the keil uvision software with the virtual uart terminal and all, everything runs fine there the baud rate shown is 9615, which i think is fairly close to 9600.

i need this for a project and unfortunately, none of my teachers have any knowledge at all about the programming of arm7. is there anything else that i can do to try n make it work???
i need two uarts, and now im thinking of degrading myself to two separate atmeg16 controllers with 2 separate uarts, interfaced through SPI for my application...

but i really really really wanna do this with arm7, i really wanna learn and implement it, but this is giving me a low down...HELP PLEASE!!

0