EmbDev.net

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


von Sascha W. (saschaw)


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.
1
#include <LPC213x.h>
2
int main( void )
3
{
4
5
  // Pins auf UART Funktion schalten
6
  PINSEL0 = (PINSEL0 & 0xfffffff0) | 0x00000005;
7
  // PLL einstellen
8
  PLLCFG = (4-1)|((2-1)<<5); // M=4 und P=2 (Multiplikatoren von 0 sind
9
nicht erlaubt)
10
  PLLCON = 0x01; // PLL aktivieren
11
12
  PLLFEED = 0xAA;  //PLL Feed-Sequenz
13
  PLLFEED = 0x55;
14
  while ( !( PLLSTAT & (1<<10) ) ); // Auf PLOCK warten
15
16
  MAMTIM = 3;
17
18
  VPBDIV = 1;
19
20
  PLLCON = 0x03; // PLL aktivieren und mit dem internen Taktgeber
21
verbinden
22
  PLLFEED = 0xAA;  //PLL Feed Sequence
23
  PLLFEED = 0x55;
24
25
  // UART0 Initalisieren
26
  U0LCR  = 0x80;                // enable access to Divisor Latches
27
28
  U0DLL = 0x20;                // PCLK = CCLK @ 58,9225 MHz
29
  U0DLM = 0x00;                // divider is 32; desired baud rate =
30
115200, real baud rate 115083
31
32
  U0LCR = 0x00;                // disable access to Divisor Latches
33
  U0LCR = 0x03;                // 8 bit, 1 Stop bit, keine parity
34
35
  U0FCR = 0x00;                //reset FIFO
36
  U0IER = 0x00;                //clear interrupt bits
37
38
  U0FCR = 0x07;                //enable UART0 FIFO
39
  U1FCR = 0x07;                //enable UART1 FIFO
40
41
  // 'a' auf UART0 ausgeben
42
  while( 1 ){                // Endlos-Schleife
43
      while (!(U0LSR & (1<<5))) continue; // Warten, bis der Sendepuffer
44
geleert ist
45
46
    // Neuen Wert in das "Transmitter Holding Register" schreiben
47
    U0THR = (char)'a';
48
  }
49
  return 0;
50
}

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.