Hi, I'm using EVK1101 and there is two push buttons PB0 and PB1 connected to pins PB02 and PB03.
I'm trying to make a simple program which will execute appropriate interrupt routine when I push the button PB0 or PB1 without using EIC controller.
// Include Files #include "board.h" #include "intc.h" #include "gpio.h" #include "print_funcs.h" #include "pm.h" // interrupt handler 1 __attribute__((__interrupt__)) static void prekidni_handler_1 (void) { print_dbg("first handler\n"); gpio_tgl_gpio_pin(LED0_GPIO); // Toggle the LED0. int i=0; while(i<65000) i++; gpio_clear_pin_interrupt_flag(AVR32_PIN_PB02); } // interrupt handler 2 __attribute__((__interrupt__)) static void prekidni_handler_2 (void) { print_dbg("second handler\n"); gpio_tgl_gpio_pin(LED1_GPIO); // Toggle the LED1. int i=0; while(i<65000) i++; gpio_clear_pin_interrupt_flag(AVR32_PIN_PB03); } int main(void) { pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); init_dbg_rs232(FOSC0); print_dbg("inicijalizacija\n"); gpio_set_gpio_pin(LED0_GPIO);//led 1 off gpio_clr_gpio_pin(LED1_GPIO);//led 2 on gpio_enable_pin_interrupt(AVR32_PIN_PB02 , GPIO_RISING_EDGE); gpio_enable_pin_interrupt(AVR32_PIN_PB03 , GPIO_RISING_EDGE); // Disable all interrupts. Disable_global_interrupt(); // Initialize interrupt vectors. INTC_init_interrupts(); INTC_register_interrupt(&prekidni_handler_1,AVR32_GPIO_IRQ_0+AVR32_PIN_PB02/8,AVR32_INTC_INT0); INTC_register_interrupt(&prekidni_handler_2,AVR32_GPIO_IRQ_0+AVR32_PIN_PB03/8,AVR32_INTC_INT0); Enable_global_interrupt(); while(1); return 0; }
This code doesn't work. It works if I use only one push button and one interrupt handler, like this one:
// Include Files #include "board.h" #include "intc.h" #include "gpio.h" #include "print_funcs.h" #include "pm.h" // interrupt handler 1 __attribute__((__interrupt__)) static void prekidni_handler_1 (void) { print_dbg("first handler\n"); gpio_tgl_gpio_pin(LED0_GPIO); // Toggle the LED0. int i=0; while(i<65000) i++; gpio_clear_pin_interrupt_flag(AVR32_PIN_PB02); } int main(void) { pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); init_dbg_rs232(FOSC0); print_dbg("inicijalizacija\n"); gpio_set_gpio_pin(LED0_GPIO);//led 1 off gpio_enable_pin_interrupt(AVR32_PIN_PB02 , GPIO_RISING_EDGE); // Disable all interrupts. Disable_global_interrupt(); // Initialize interrupt vectors. INTC_init_interrupts(); INTC_register_interrupt(&prekidni_handler_1,AVR32_GPIO_IRQ_0+AVR32_PIN_PB02/8,AVR32_INTC_INT0); Enable_global_interrupt(); while(1); return 0; }
What is wrong with the first code?