Arduino Due ADC Interrupt does not work

Hi,
the following code should set up an ADC, then call an interrupt function each time a value is converted, but this doesn’t work. I suspect that the interrupt function is not called.
In the loop function I start the ADC, then wait some time, if the interrupt is called the led is switched on. The wait function waits for about one second, and the ADC conversion takes only 6us, so I should see the led switched on for about one second, but actually this doesn’t happen. So this means that the interrupt function is not called.
When I connect the Arduino to a serial monitor I get the correct values from the ADC, so I don’t think that it is a problem with the ADC.

Here is my code:

enum adc_channel_num_t list[1];

void setup()
{
    // Output Enable Register
    REG_PIOB_OER = PIO_PB27; // (PB27 is pin 13)
    
    
    Serial.begin(9600);
    
    adc_set_writeprotect(ADC, 0); // disable write protect
    // Sets ADC
    adc_init(ADC, F_CPU, 6000000, 0); // inits ADC conversion
    adc_set_resolution(ADC, ADC_12_BITS); // sets 12 bit prescaler
    adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
    adc_enable_anch(ADC); // <--- Not really necessary
    adc_enable_tag(ADC); // <--- Not really necessary
    adc_enable_ts(ADC); // Temperature sensor, not really necessary
    
    // Sets ADC channels
    list[0] = ADC_CHANNEL_0;
    adc_disable_all_channel(ADC); // disables all channels
    adc_enable_channel(ADC, list[0]); // and re-enables only the needed
    adc_start_sequencer(ADC); // use sequencer
    adc_configure_sequence(ADC, list, 1); // Sets up sequencer
    
    adc_set_channel_input_gain(ADC, list[0], ADC_GAINVALUE_3); // sets signal gain
    
    adc_enable_interrupt(ADC, 1 << ADC_IER_DRDY); // sets interrupt when conversion on channel 0 ends
    NVIC_EnableIRQ(ADC_IRQn);
    adc_set_writeprotect(ADC, 1); // re-enable write protect
    
    // Sets timer
    //TC0->TC0_CMR = 0;
}

// the loop routine runs over and over again forever:
void loop()
{
    unsigned int s, e;
    s = micros();
    adc_start(ADC);
    while (!(ADC->ADC_ISR & ADC_ISR_DRDY));
    e = micros();
    wait();
    REG_PIOB_CODR = PIO_PB27; // Clear Output Data Register, turns LED off
    wait();
    
    int var = ADC->ADC_LCDR;
    Serial.print(e-s);
    Serial.print(" ");
    prnt(var);
}

void prnt(int x) {
  for (unsigned int mask = 0x80000000; mask; mask >>= 1)
    if (x & mask)
       Serial.write("1");
    else
       Serial.write("0");
   Serial.write("\n");
}

void wait() {
    int n;
    for (n = 0; n < F_CPU/4; n++)
        asm volatile ("nop\n\t");
}

void ADC_Handler(void) {
  REG_PIOB_SODR = PIO_PB27; // Set Output Data Register, turns LED on
}

Thank you in advance

Almost solved: in the setup function, at line 30 it should be

adc_enable_interrupt(ADC, ADC_IER_DRDY);

But the led doesn't blink as expected, instead it simply switch on. It seems that the interrupt is executed, but it never returns to the normal program flow. Disabling the interrupt the program works correctly

[SOLVED]

in the ADC_Handler just read the data: last conversion if interrupt on DRDY, or the corresponding channel if interrupt is on EOCx.

The interrupt is called when it is set one bit of ADC_ISR (Interrupt Status Register), and its bits are sets when new data is ready to read, and cleared when data is read. So, without reading the corresponding bit in ADC_ISR remains 1, and so the interrupt is continually executed.