Hy, i have bought a ADuC7126 Eval-Board. There is a Switch for IRQ0 on P0.4 and an LED on P4.2 to VDDIO. I've studied the example XirqTest.c and tried to make the LED toggle each time the switch is pressed
#include <aduc7126.h> #define BIT17 0x00020000 int main(void) { unsigned char n; volatile unsigned long int a; POWKEY1 = 0x01; // Configure CPU to active mode, CD=0: Clock for 41.78MHz POWCON0 = 0x00; POWKEY2 = 0xF4; GP4DAT = 0x04000000; // P4.2 (LED D2) is Output IRQCONE = 0x2; // External IRQ0 triggers on rising edge. IRQEN |= BIT17; for(n=9;n;--n) { for(a=1000000;a;--a){} GP4DAT ^= 0x00040000; // Hardwaretest LED P4.2 toggle } while(1){} } //************************************************************** void IRQ_Handler(void) __irq { IRQCLRE = BIT17; GP4DAT ^= 0x00040000; // LED an P4.2 toggeln }
Of course i have tested the pure Hardeware function of this switch before.
while(1){} { if(GP0DAT & 0x00000010) // switch on P0.4 GP4SET = 0x00040000; // LED P4.2 off else GP4CLR = 0x00040000; // LED P4.2 on }
Now i'm a little desperate cause there is no reaction to pressing Switch.