External Interrupt only hits once

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

I am working with a SAMG55, and am using the ASF4/Atmel start framework for my project.  I am using the SW0 button on my xplained pro board as the interrupt trigger.  I have it set for falling edge, so each time I press it, I should get an interrupt.  I hit my interrupt the first time I press the button, but then I do not get the interrupt/get in my ISR anymore.  I have looked at an example in the Start webpage, but  nothing seems to be working.  I have included some of the relevant code below.  I am just doing some while loops, waiting for the button to be pressed, when it is I do other stuff in a while loop, and wait for the button to be pressed again.  I even went to the Atmel start page and configured a project ONLY with the EXT IRQ and am still getting the same results.  I checked the config file and it looks correct too (correct values for falling edge and enable). I also tried to disable the EXT IRQ and then re enable it, but no change.  I have done something similar with a SAMB11, but the external interrupt was from a chip,and not a button.  Anyone have any ideas? Is there something I should do in my ISR to let it run again?

 

volatile uint8_t button_press;

 

ext_irq_enable(PA2);
ext_irq_register(PA2,button_press_isr);

 

static void button_press_isr(void)
{
    
    button_press ^=0x01;
    
}

 

void EXTERNAL_IRQ_0_init(void)
{
    // Set pin direction to input
    gpio_set_pin_direction(PA2, GPIO_DIRECTION_IN);

    gpio_set_pin_pull_mode(PA2,
    // <y> Pull configuration
    // <id> pad_pull_config
    // <GPIO_PULL_OFF"> Off
    // <GPIO_PULL_UP"> Pull-up
    // <GPIO_PULL_DOWN"> Pull-down
    GPIO_PULL_OFF);

    gpio_set_pin_function(PA2, GPIO_PIN_FUNCTION_OFF);
}

 

void system_init(void)
{
    init_mcu();
    _pmc_enable_periph_clock(ID_PIOA);
    /* Disable Watchdog */
    hri_wdt_set_MR_WDDIS_bit(WDT);

    EXTERNAL_IRQ_0_init();

    CALENDAR_0_init();

    TIMER_0_init();

    I2C_0_init();

    SPI_0_init();
    USART_0_init();

    USB_DEVICE_INSTANCE_init();

    ext_irq_init();
}

 

 

 

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

Not sure if you are using a custom board or one of the Atmel XPlained boards.  First check your schematic and trace the GPIO pin through the button and everywhere else it goes.  There should be a pull-up or pull-down resistor somewhere with the button when pressed going to GND or VCC.

 

I'm betting there is no pull-up/pull-down resistor on the PCB therefore you need to enable the proper one inside the microprocessor.

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

OK, misread your post, you are using the Xplained board.  Assuming it's the SAM G55 Xplained Pro Evaluation Kit, download the design document PDF and check the schematic.  SW0 button on the silkscreen maps to SW300 on the schematic.

 

 

SW300 on the schematic is this:

 

 

When the button SW300 is pressed PA02 goes to ground.  But there is no pull-up to return PA02 back to VCC.  You need to enable the internal pull-up on the GPIO pin.  See the revised code snippet below.

 

void EXTERNAL_IRQ_0_init(void)
{
    // Set pin direction to input
    gpio_set_pin_direction(PA2, GPIO_DIRECTION_IN);

    gpio_set_pin_pull_mode(PA2,
    // <y> Pull configuration
    // <id> pad_pull_config
    // <GPIO_PULL_OFF"> Off
    // <GPIO_PULL_UP"> Pull-up
    // <GPIO_PULL_DOWN"> Pull-down
    GPIO_PULL_UP);  // <----- enable the internal pull-up with this line

    gpio_set_pin_function(PA2, GPIO_PIN_FUNCTION_OFF);
}

 

Try this change and be sure to post your results.