Hallo,
ich möchte über einen Button auf meinem Olimex sam7ex256 Board ein
Interrupt auslösen. Die Interrupt-Routine soll eigentlich nur eine LED
schalten. Nun ist es aber so, dass so ziemlich genau garnichts beim
Betätigen des Buttons passiert. Hier mal der Code:
1 | void irq_int(void) __irq
|
2 | {
|
3 |
|
4 | if ((m_pPioB->PIO_PDSR & AT91C_PIO_PB25) == 0)
|
5 | {
|
6 | setLED(LED_YELLOW);
|
7 | }
|
8 |
|
9 | *AT91C_AIC_EOICR = 0; /* End of Interrupt */
|
10 | }
|
11 |
|
12 |
|
13 | int main()
|
14 | {
|
15 | int index;
|
16 |
|
17 | AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, ( 1 << AT91C_ID_PIOA ) | ( 1 << AT91C_ID_PIOB ));
|
18 | configureLED(AT91C_PIO_PA3 | AT91C_PIO_PA4 | AT91C_PIO_PA27);
|
19 |
|
20 | uart0_init();
|
21 | clear_screen();
|
22 |
|
23 | m_pPioB->PIO_PPUDR = AT91C_PIO_PB25; // disable pull-up (is external)
|
24 | m_pPioB->PIO_IFER = AT91C_PIO_PB25; // enable filter
|
25 | m_pPioB->PIO_ODR = AT91C_PIO_PB25; // disable output
|
26 | m_pPioB->PIO_SODR = AT91C_PIO_PB25; // set high
|
27 | m_pPioB->PIO_PER = AT91C_PIO_PB25; // enable
|
28 | m_pPioB -> PIO_IER = AT91C_PIO_PB25; // enable interrupt
|
29 |
|
30 | AT91C_BASE_AIC->AIC_IDCR = 1 << AT91C_ID_PIOB;
|
31 | AT91C_BASE_AIC->AIC_SMR[AT91C_ID_PIOB] = AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE | 6;
|
32 | AT91C_BASE_AIC->AIC_SVR[AT91C_ID_PIOB] = (unsigned int) irq_int;
|
33 | AT91C_BASE_AIC->AIC_ICCR = 1 << AT91C_ID_PIOB;
|
34 | AT91C_BASE_AIC->AIC_IECR = 1 << AT91C_ID_PIOB;
|
35 |
|
36 | for(;;)
|
37 | {
|
38 | setLED(LED_RED);
|
39 | index = 0;
|
40 |
|
41 | while(index < 500000) index++;
|
42 |
|
43 | index = 0;
|
44 | resetLED(LED_RED);
|
45 |
|
46 | while(index < 500000) index++;
|
47 | }
|
48 | }
|
Das ist der Code. Ganz klein und eigentlich ganz simpel. Das betätigen
bzw. registrieren des Buttons, welcher an dem PIO_25 als Input gesetzt
ist funktioniert einwandfrei. Aber irgendwie funktioniert der Interrupt
nicht. Hab ich etwas grundlegendes vergessen?
Ich arbeite übrigens mit Keil 4. Ich habe mir schon unzählige Beispiele
angeschaut. Und ich weiß mittlerweile nicht mehr wo da ein Fehler
enthalten sein könnte. Wenn jemand einen Tipp für mich hätte würde ich
mich sehr freuen.