SAMC20J external interrupt

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

Hi guys,

I've started a new project using atmel getting started and added an external interrupt. PIN_PB03 configured as an input, LED as an output.

#include <atmel_start.h>
#include "driver_examples.h"
#include "hal_gpio.h"

void __enable_irq(void);

int main(void)
{
    /* Initializes MCU, drivers and middleware */
    atmel_start_init();
    /* Replace with your application code */
    EXTERNAL_IRQ_0_example();

    ext_irq_enable(PIN_PB03);
    
    //NVIC_EnableIRQ(PINMUX_PB03A_EIC_EXTINT3);
    while (1) {
        delay_ms(10);
    
        
        /*
        if (gpio_get_pin_level(SWITCH))
        {
            gpio_set_pin_level(LED,true);
        }
        else
        {
            gpio_set_pin_level(LED,false);
        }
        */
        
    }
}

static void button_on_PB03_pressed(void)
{
        gpio_toggle_pin_level(LED);
}

/**
 * Example of using EXTERNAL_IRQ_0
 */
void EXTERNAL_IRQ_0_example(void)
{

    ext_irq_register(PIN_PB03, button_on_PB03_pressed);
}
 

Works just fine when checking pin manually. Dos'nt work at all when using an interrupt.

Any ideas?  

This topic has a solution.
Last Edited: Tue. Mar 19, 2019 - 12:59 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For future readers.

The solution is very easy, just enable interrupt in Atmel Studio.

solution