Unable to generate interrupt

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I am trying to test the interrupt code by trigger LED0 onboard pin. I have used pin 7A as interrupt pin. When, I give logic 1 by using a pushbutton that is connected to 3.3V, the onboard LED keeps on glowing even after I release the pushbutton. What could be the issue here? any recommendations on this?

 

 

 

#include <asf.h>

#define EIC_LINE 7
#define sensorPin PIN_PA07

void configure_extint_channel(void);
void configure_extint_callbacks(void);
void extint_detection_callback(void);

//! [setup]
void configure_extint_channel(void)
{
//! [setup_1]
    struct extint_chan_conf config_extint_chan;
//! [setup_1]
//! [setup_2]
    extint_chan_get_config_defaults(&config_extint_chan);
//! [setup_2]

//! [setup_3]
    config_extint_chan.gpio_pin           = PIN_PA07A_EIC_EXTINT7;
    config_extint_chan.gpio_pin_mux       = MUX_PA07A_EIC_EXTINT7;

    config_extint_chan.gpio_pin_pull      = EXTINT_PULL_DOWN;
    config_extint_chan.detection_criteria = EXTINT_DETECT_HIGH;
//! [setup_3]
//! [setup_4]
    extint_chan_set_config(EIC_LINE, &config_extint_chan);
//! [setup_4]
}

void configure_extint_callbacks(void)
{
//! [setup_5]
    extint_register_callback(extint_detection_callback,
            EIC_LINE,
            EXTINT_CALLBACK_TYPE_DETECT);
//! [setup_5]
//! [setup_6]
    extint_chan_enable_callback(EIC_LINE,
            EXTINT_CALLBACK_TYPE_DETECT);
//! [setup_6]
}

//! [setup_7]
void extint_detection_callback(void)
{
    bool pin_state = port_pin_get_input_level(sensorPin);
    port_pin_set_output_level(LED_0_PIN, pin_state);
    

}
//! [setup_7]
//! [setup]

int main(void)
{
    system_init();

    //! [setup_init]
    configure_extint_channel();
    configure_extint_callbacks();

    system_interrupt_enable_global();
    //! [setup_init]

    //! [main]
    while (true) {
        
    }
    //! [main]
}
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chiranjibi Subedi wrote:

Hi, I am trying to test the interrupt code by trigger LED0 onboard pin. I have used pin 7A as interrupt pin. When, I give logic 1 by using a pushbutton that is connected to 3.3V, the onboard LED keeps on glowing even after I release the pushbutton. What could be the issue here? any recommendations on this?

 

 

 

#include <asf.h>

#define EIC_LINE 7
#define sensorPin PIN_PA07

void configure_extint_channel(void);
void configure_extint_callbacks(void);
void extint_detection_callback(void);

//! [setup]
void configure_extint_channel(void)
{
//! [setup_1]
    struct extint_chan_conf config_extint_chan;
//! [setup_1]
//! [setup_2]
    extint_chan_get_config_defaults(&config_extint_chan);
//! [setup_2]

//! [setup_3]
    config_extint_chan.gpio_pin           = PIN_PA07A_EIC_EXTINT7;
    config_extint_chan.gpio_pin_mux       = MUX_PA07A_EIC_EXTINT7;

    config_extint_chan.gpio_pin_pull      = EXTINT_PULL_DOWN;
    config_extint_chan.detection_criteria = EXTINT_DETECT_HIGH;
//! [setup_3]
//! [setup_4]
    extint_chan_set_config(EIC_LINE, &config_extint_chan);
//! [setup_4]
}

void configure_extint_callbacks(void)
{
//! [setup_5]
    extint_register_callback(extint_detection_callback,
            EIC_LINE,
            EXTINT_CALLBACK_TYPE_DETECT);
//! [setup_5]
//! [setup_6]
    extint_chan_enable_callback(EIC_LINE,
            EXTINT_CALLBACK_TYPE_DETECT);
//! [setup_6]
}

//! [setup_7]
void extint_detection_callback(void)
{
    bool pin_state = port_pin_get_input_level(sensorPin);
    port_pin_set_output_level(LED_0_PIN, pin_state);
    

}
//! [setup_7]
//! [setup]

int main(void)
{
    system_init();

    //! [setup_init]
    configure_extint_channel();
    configure_extint_callbacks();

    system_interrupt_enable_global();
    //! [setup_init]

    //! [main]
    while (true) {
        
    }
    //! [main]
}
 

was a hardware issue. Works now.