EmbDev.net

Forum: ARM programming with GCC/GNU tools Uart ARM LPC2138


Author: Sascha Winter (saschaw)
Posted on:

Rate this post
0 useful
not useful
Hi!

I have got an problem using the uart of the LPC2138. I`m using the
EmbeddedArtists LPC2138 QuickStart Board. I get either no output on the
terminal or useless output.
#include <LPC213x.h>

int main( void )
{

  // Pins auf UART Funktion schalten
  PINSEL0 = (PINSEL0 & 0xfffffff0) | 0x00000005;
  // PLL einstellen
  PLLCFG = (4-1)|((2-1)<<5); // M=4 und P=2 (Multiplikatoren von 0 sind
nicht erlaubt)
  PLLCON = 0x01; // PLL aktivieren

  PLLFEED = 0xAA;  //PLL Feed-Sequenz
  PLLFEED = 0x55;
  while ( !( PLLSTAT & (1<<10) ) ); // Auf PLOCK warten

  MAMTIM = 3;

  VPBDIV = 1;

  PLLCON = 0x03; // PLL aktivieren und mit dem internen Taktgeber
verbinden
  PLLFEED = 0xAA;  //PLL Feed Sequence
  PLLFEED = 0x55;

  // UART0 Initalisieren
  U0LCR  = 0x80;                // enable access to Divisor Latches

  U0DLL = 0x20;                // PCLK = CCLK @ 58,9225 MHz
  U0DLM = 0x00;                // divider is 32; desired baud rate =
115200, real baud rate 115083

  U0LCR = 0x00;                // disable access to Divisor Latches
  U0LCR = 0x03;                // 8 bit, 1 Stop bit, keine parity

  U0FCR = 0x00;                //reset FIFO
  U0IER = 0x00;                //clear interrupt bits

  U0FCR = 0x07;                //enable UART0 FIFO
  U1FCR = 0x07;                //enable UART1 FIFO

  // 'a' auf UART0 ausgeben
  while( 1 ){                // Endlos-Schleife
      while (!(U0LSR & (1<<5))) continue; // Warten, bis der Sendepuffer
geleert ist

    // Neuen Wert in das "Transmitter Holding Register" schreiben
    U0THR = (char)'a';
  }
  return 0;
}

Thanks

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.