Interrupts under AT32UC3C0512

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

Hi,

I´m trying to setup an interrupt handler to get the results from an external ADC based on the rising edge of a DATA_READY signal connected to a GPIO line

I'm using the following:

#define ADC_RDY_PIN   AVR32_PIN_PA10    // Output signal that indicates ADC conversion completion	
ioport_set_pin_dir(ADC_RDY_PIN,  IOPORT_DIR_INPUT);
Disable_global_interrupt();
	
gpio_enable_pin_interrupt(ADC_RDY_PIN, GPIO_RISING_EDGE);
	    
INTC_init_interrupts();

INTC_register_interrupt(&read_ADC, AVR32_GPIO_IRQ_0 + (ADC_RDY_PIN/8 ), AVR32_INTC_INT0);
	
Enable_global_interrupt();

The handler is defined as:

__attribute__((__interrupt__)) static void read_ADC( void )
{

	
gpio_clear_pin_interrupt_flag(ADC_RDY_PIN);
	
// Code to read the ADC

}

With the debugger I can see the handler is called but it looks like it is constantly called and the control is never returned. Everytime I stop the debugger the CPU is always stuck at the default interrupt handler:

static void _unhandled_interrupt(void)
{
	// Catch unregistered interrupts.
	while (true);
}

So maybe the problema is somewhere else but I can´t found where :cry:

I´ve tried to change the code to use the EIC instead but withou luck either...

Suggestions are most welcome!

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

OK, I´ve found the problema. It´s on
INTC_init_interrupts(). I´m also using the TWIM functions which are interrupt based. By calling
INTC_init_interrupts() I was wipping the vector for the TWIM interrupt handler and this is why the CPU was always ending in the default interrupt handler evrytime I trying to use the I2C (TWIM) bus :roll: