Guten Tag miteinander.
Habe da ein Problem mit meinem Projekt auf dem LPC 2378 und dem Olimex
LPC-2378-STK Board.
Arbeite mit der Kickstartversion von IAR und habe deren uIP Beispiel mir
vorgenommen. In dieses Projekt habe ich versucht noch UART zu
integrieren, unter anderem mit Hilfe der Beispiele für WinARM und der
von IAR.
WebServer läuft immer noch, LCD ebenfalls, aber das Senden über UART
nicht ganz. Es wird zwar was gesendet, aber die falschen Zeichen. Hoffe
jemand kann mir weiterhelfen, sitze schon seit Tagen dran und weiß nicht
mehr wo ich noch nach Fehler suchen soll.
Hier mal meine Code-Ausschnitte
1 | void uart1Init(DWORD baud)
|
2 | {
|
3 | DWORD Fdiv;
|
4 |
|
5 | PINSEL0 |= 0x40000000; /* Enable TxD1 P0.15 */
|
6 | PINSEL1 |= 0x00000001; /* Enable RxD1 P0.16 */
|
7 |
|
8 | U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
|
9 | Fdiv = ( Fpclk / 16 ) / baud;
|
10 | U1DLM = Fdiv / 256;
|
11 | U1DLL = Fdiv % 256;
|
12 | U1LCR = 0x03; /* DLAB = 0 */
|
13 | U1FCR = 0x07; /* Enable and reset TX and RX FIFO. */
|
14 |
|
15 |
|
16 | VICINTSELECT &= ~VIC_BIT(VIC_UART1); // UART1 selected as IRQ
|
17 | VICINTENABLE = VIC_BIT(VIC_UART1); // UART1 interrupt enabled
|
18 |
|
19 | VICVECTPRIORITY1 = VIC_ENABLE | VIC_UART1;
|
20 | VICVECTADDR1 = (Int32U)uart1ISR; // address of the ISR
|
21 | }
|
1 | void uart1ISR(void)
|
2 | {
|
3 | Int8U iid;
|
4 |
|
5 | // loop until not more interrupt sources
|
6 | while (((iid = U1IIR) & UIIR_NO_INT) == 0)
|
7 | {
|
8 | // identify & process the highest priority interrupt
|
9 | switch (iid & UIIR_ID_MASK)
|
10 | {
|
11 | case UIIR_RLS_INT: // Receive Line Status
|
12 | U1LSR; // read LSR to clear
|
13 | break;
|
14 | case UIIR_CTI_INT: // Character Timeout Indicator
|
15 | case UIIR_RDA_INT: // Receive Data Available
|
16 | do
|
17 | {
|
18 | Int16U temp;
|
19 |
|
20 | // calc next insert index & store character
|
21 | temp = (uart1_rx_insert_idx + 1) % UART1_RX_BUFFER_SIZE;
|
22 | uart1_rx_buffer[uart1_rx_insert_idx] = U1RBR;
|
23 |
|
24 | // check for more room in queue
|
25 | if (temp != uart1_rx_extract_idx)
|
26 | uart1_rx_insert_idx = temp; // update insert index
|
27 | }
|
28 | while (U1LSR & ULSR_RDR);
|
29 |
|
30 | break;
|
31 |
|
32 | case UIIR_THRE_INT: // Transmit Holding Register Empty
|
33 | while (U1LSR & ULSR_THRE)
|
34 | {
|
35 | // check if more data to send
|
36 | if (uart1_tx_insert_idx != uart1_tx_extract_idx)
|
37 | {
|
38 | U1THR = uart1_tx_buffer[uart1_tx_extract_idx++];
|
39 | uart1_tx_extract_idx %= UART1_TX_BUFFER_SIZE;
|
40 | }
|
41 | else
|
42 | {
|
43 | // no
|
44 | uart1_tx_running = 0; // clear running flag
|
45 | break;
|
46 | }
|
47 | }
|
48 |
|
49 | break;
|
50 |
|
51 | case UIIR_MS_INT: // MODEM Status
|
52 | U1MSR; // read MSR to clear
|
53 | break;
|
54 |
|
55 | default: // Unknown
|
56 | U1LSR;
|
57 | U1RBR;
|
58 | U1MSR;
|
59 | break;
|
60 | }
|
61 | }
|
62 |
|
63 | VICADDRESS = 0x00000000; // clear this interrupt from the VIC
|
64 |
|
65 | }
|
1 | const char *uart1Puts(const char *string)
|
2 | {
|
3 | register char ch;
|
4 |
|
5 | while ((ch = *string) && (uart1Putch(ch) >= 0))
|
6 | string++;
|
7 |
|
8 | return string;
|
9 | }
|
10 |
|
11 | int uart1Putch(int ch)
|
12 | {
|
13 | Int16U temp;
|
14 |
|
15 | temp = (uart1_tx_insert_idx + 1) % UART1_TX_BUFFER_SIZE;
|
16 |
|
17 | if (temp == uart1_tx_extract_idx)
|
18 | return -1; // no room
|
19 |
|
20 | // check if in process of sending data
|
21 | if (uart1_tx_running)
|
22 | {
|
23 | // add to queue
|
24 | uart1_tx_buffer[uart1_tx_insert_idx] = (Int8U)ch;
|
25 | uart1_tx_insert_idx = temp;
|
26 | }
|
27 | else
|
28 | {
|
29 | // set running flag and write to output register
|
30 | uart1_tx_running = 1;
|
31 | U1THR = (Int8U)ch;
|
32 | }
|
33 |
|
34 | return (Int8U)ch;
|
35 | }
|