Uart ARM LPC2138

OP #1172721
Rate this post
• ▲ 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.
1
#include <LPC213x.h>
2

3
int main( void )
4
{
5

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

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

17
  MAMTIM = 3;
18

19
  VPBDIV = 1;
20

21
  PLLCON = 0x03; // PLL aktivieren und mit dem internen Taktgeber
22
verbinden
23
  PLLFEED = 0xAA;  //PLL Feed Sequence
24
  PLLFEED = 0x55;
25

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

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

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

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

39
  U0FCR = 0x07;                //enable UART0 FIFO
40
  U1FCR = 0x07;                //enable UART1 FIFO
41

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

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

Thanks

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.