Hallo!
Ich versuche den UART0 bei einem LPC2138 ein zu richten. Leider bekomme
ich entweder keine, oder keine Sinnvolle Ausgabe auf das Terminal.
Ich verwende das Embedded Artist QuickStart Board.
Hier mein Code:
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 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 verbinden
|
21 | PLLFEED = 0xAA; //PLL Feed Sequence
|
22 | PLLFEED = 0x55;
|
23 |
|
24 | // UART0 Initalisieren
|
25 | U0LCR = 0x80; // enable access to Divisor Latches
|
26 |
|
27 | U0DLL = 0x20; // PCLK = CCLK @ 58,9225 MHz
|
28 | U0DLM = 0x00; // divider is 32; desired baud rate = 115200, real baud rate 115083
|
29 |
|
30 | U0LCR = 0x00; // disable access to Divisor Latches
|
31 | U0LCR = 0x03; // 8 bit, 1 Stop bit, keine parity
|
32 |
|
33 | U0FCR = 0x00; //reset FIFO
|
34 | U0IER = 0x00; //clear interrupt bits
|
35 |
|
36 | U0FCR = 0x07; //enable UART0 FIFO
|
37 | U1FCR = 0x07; //enable UART1 FIFO
|
38 |
|
39 | // 'a' auf UART0 ausgeben
|
40 | while( 1 ){ // Endlos-Schleife
|
41 | while (!(U0LSR & (1<<5))) continue; // Warten, bis der Sendepuffer geleert ist
|
42 |
|
43 | // Neuen Wert in das "Transmitter Holding Register" schreiben
|
44 | U0THR = (char)'a';
|
45 | }
|
46 | return 0;
|
47 | }
|
Ich bin für jeden Vorschlag offen.