Hallo ins Forum,
ich bin etwas ratlos: Ich nutze einen LPC11U68JBD48 für ein Projekt. Es
gelingt mir nicht, einige bestimmte Ports als Ausgang zu schalten und zu
setzen bzw. zu clearen. Diese besagten Ports bleiben IMMER high. Dachte
zu erst daran, dass hier ein Hardwarefehler (Lötbrücke oder so)
vorliegt. Aber das ist nachgewiesener Weise nicht der Fall.
Beispielcode, mit dem sich das Problem darstellen läßt:
1 | int main(void) {
|
2 |
|
3 | int j = 0;
|
4 |
|
5 | LPC_SYSCON->SYSAHBCLKCTRL |= ((uint32_t)1<<16); // GPIO clocks an
|
6 |
|
7 | LPC_GPIO_PORT->DIR[1] |= ((uint32_t)1 << 20); // LED blau
|
8 |
|
9 | // 4 Pins testweise als Ausgang
|
10 | LPC_GPIO_PORT->DIR[0] |= (1 << 2);
|
11 | LPC_GPIO_PORT->DIR[0] |= ((uint32_t)1 << 12);
|
12 | LPC_GPIO_PORT->DIR[0] |= ((uint32_t)1 << 13);
|
13 | LPC_GPIO_PORT->DIR[0] |= ((uint32_t)1 << 20);
|
14 |
|
15 | // Diese 4 Pins auf low
|
16 | LPC_GPIO_PORT->CLR[0] |= (1 << 2);
|
17 | LPC_GPIO_PORT->CLR[0] |= ((uint32_t)1 << 12);
|
18 | LPC_GPIO_PORT->CLR[0] |= ((uint32_t)1 << 13);
|
19 | LPC_GPIO_PORT->CLR[0] |= ((uint32_t)1 << 20);
|
20 |
|
21 | while(1) {
|
22 | // Die LED und die 4 pins toggeln...
|
23 | LPC_GPIO_PORT->NOT[1] |= ((uint32_t)1 << 20); // LED blau blinkt --> korrekt
|
24 | LPC_GPIO_PORT->NOT[0] |= (1 << 2); // Pin toggelt --> korrekt
|
25 | LPC_GPIO_PORT->NOT[0] |= ((uint32_t)1 << 12); // Pin bleibt auf high --> falsch
|
26 | LPC_GPIO_PORT->NOT[0] |= ((uint32_t)1 << 13); // Pin bleibt auf high --> falsch
|
27 | LPC_GPIO_PORT->NOT[0] |= ((uint32_t)1 << 20); // Pin bleibt auf high --> falsch
|
28 |
|
29 | for(j = 0; j < 400000; j++);
|
30 | }
|
31 |
|
32 | return 0;
|
33 | }
|
Hatte schon gedacht, es hat was mit den Bitmanipulationen bei 32bit
Registern zu tun. Aber die LED blinkt. Also funktioniert das soweit. Hat
jemand eine Idee?
Gruß Uli