Hallo Zusammen,
ich möchte über den LPC4088 mittels UART daten vom PC an den µC senden.
Der Datentransfer von µC zu PC funktioniert einwandfrei.
Nach der Initialisierung springe ich in meine Funktion die solange
wartet bis Daten im RX FIFO gelandet sind. Problem: Das RDR bit wird
niemals 1, also sind auch keine Daten im Buffer.
Ich hab bereits meine Schnittstelle mit dem Oszi überprüft ob der Fehler
möglicherweise meine Schnittstelle ist, aber die Funktioniert
einwandfrei.
Vielleich weiß jemand von euch eine Lösung
Grüße Tim
1 | void UART3_Init(void){
|
2 | LPC_SYSCTL->PCONP |= (1 << 25); // Enable Power & CLock for UART3
|
3 | LPC_UART3->LCR = (3 << 0) // Word Length: 8 Bit
|
4 | |(0 << 2) // Stop Bit: 1 Bit
|
5 | |(0 << 3) // Parity Enable: disabled
|
6 | |(1 << 7); // Divisor Latch: enabled
|
7 | LPC_UART3->DLL = 65; // Divisor Latch: 65 for 115200 Baud
|
8 | LPC_UART3->DLM = 0; // Divisor Latch: 0 for 115200 Baud
|
9 | LPC_UART3->FCR = (1 << 0) // FIFO enable: enabled
|
10 | |(1 << 1) // RX FIFO reset: enabled
|
11 | |(1 << 2); // TX FIFO reset: enabled
|
12 | LPC_UART3->FDR = (0 << 0) // Baudrate prescaler Value: DIVADDL = 0
|
13 | |(1 << 4); // Baudrate prescaler Value: MULVAL = 1
|
14 | LPC_UART3->LCR &= ~(1 << 7); // disable to lock Baud - without this no UART communication
|
15 | }
|
16 |
|
17 |
|
18 | char UART3_receive(void){
|
19 | while(!(LPC_UART3->LSR & (1 << 0))); //wait until data arrives in Rx FIFO
|
20 | return LPC_UART3->RBR;
|
21 | }
|
22 |
|
23 | int main(void){
|
24 | //CCLK runs with 120MHz
|
25 |
|
26 | //UART 3 Pins
|
27 | LPC_IOCON->p[0][25] = (3 << 0); //UART3 TX p[0][25]
|
28 | LPC_GPIO->DIR |= (1 << 25);
|
29 | LPC_IOCON->p[0][26] = (3 << 0); //UART3 RX p[0][26]
|
30 | LPC_GPIO->DIR &= ~(1 << 26);
|
31 |
|
32 | //UART3 with 115200,8,1,N
|
33 | UART3_Init();
|
34 |
|
35 | char data = 0;
|
36 |
|
37 | while(1){
|
38 | data = UART3_receive();
|
39 |
|
40 | if(data == ENTER){
|
41 | //PRINT back to terminal "SUCCESS"
|
42 | ...
|
43 | ...
|
44 | }
|
45 | }
|
46 | }
|