Hi,
ich bin gerade dabei meinen UART0 von meinem lpc1768 in betrieb zu
nehmen.
Das Senden von Bytes funktioniert auch wunderbar.
Baudrate 115200 8N1
P0.2 u P0.3 sind auf UART gestellt.
FIFOS sind enabled.
NVIC_EnableIRQ(UART0_IRQn) ebenso.
Jetzt habe ich eine ISR implementiert doch leider passiert nicht viel.
Ich versuche ueber Minicom Bytes zu senden.
Ich lande leider nur in der ISR bei einem THRE aber nicht bei einem RBR
wenn ich in minicom Bytes sende.
1 | #include <lpc17xx.h>
|
2 | #include <stdio.h>
|
3 |
|
4 | void UART0_IRQHandler() {
|
5 |
|
6 | uint8_t irq_mode = LPC_UART0->IIR;
|
7 | irq_mode >>= 1;
|
8 | irq_mode &= 0x07;
|
9 |
|
10 | // Receive Data Avaliable
|
11 | if(irq_mode == 0x02) {
|
12 | printf("RBR\n");
|
13 | }
|
14 |
|
15 | // Receive Line Status
|
16 | if(irq_mode == 0x03) {
|
17 | printf("RLS\n");
|
18 | }
|
19 |
|
20 | // Character Time-out Indicator
|
21 | if(irq_mode == 0x05) {
|
22 | printf("CTI\n");
|
23 | }
|
24 |
|
25 | // Tranceive Register Empty
|
26 | if(irq_mode == 0x01) {
|
27 | //printf("THRE\n");
|
28 | }
|
29 |
|
30 | }
|
Hier noch meine init function
1 | void initSystem() {
|
2 |
|
3 | // set gpio function
|
4 | LPC_PINCON->PINSEL7 &= ~(0x3U << 18);
|
5 | LPC_PINCON->PINSEL7 &= ~(0x3U << 20);
|
6 |
|
7 | // set gpio pull-down
|
8 | LPC_PINCON->PINMODE7 |= (0x3U << 18);
|
9 | LPC_PINCON->PINMODE7 |= (0x3U << 20);
|
10 |
|
11 | // set gpio as output
|
12 | LPC_GPIO3->FIODIR |= (1U << 25);
|
13 | LPC_GPIO3->FIODIR |= (1U << 26);
|
14 |
|
15 | // setup uart0
|
16 | LPC_PINCON->PINSEL0 |= (1 << 4) | (1 << 6);
|
17 | LPC_UART0->LCR = 0x83; // 8bit, no parity, 1 stop bit, DLAB=1
|
18 | LPC_UART0->DLL = 0x0D; // divide by 13
|
19 | LPC_UART0->DLM = 0x00;
|
20 | LPC_UART0->LCR &= ~(0x01U << 7); // disable DLAB
|
21 | LPC_UART0->FCR = 0x07; // enable fifo's, interrupt if 1 char
|
22 |
|
23 | NVIC_EnableIRQ(UART0_IRQn);
|
24 |
|
25 | LPC_UART0->IER |= (0x07U << 0); // enable interrupt if data received
|
26 |
|
27 | }
|
Jemand eine idee?
Vielen Danke im voraus.