Use of Handler in the Arduino code

Hello all,

I wonder what exactly the handler are, and how to use them (precisely for the Arduino Due). I mean these functions which we find in some codes: ADC_Handler oder DACC_Handler. Are they specific Interrupt Service Routines for the ADC and DACC converters of the microcontroller?

Thanks in advance for your precious answer(s).

You provide a handler routine and enable the relevant interrupt.

For instance here's an ADC handler from one of my test sketches

void ADC_Handler (void)
  if (ADC->ADC_ISR & ADC_ISR_EOC7)   // ensure there was an End-of-Conversion and we read the ISR reg
    int val = *(ADC->ADC_CDR+7) ;    // get conversion result
    samples [sptr] = val ;           // stick in circular buffer
    sptr = (sptr+1) & BUFMASK ;      // move pointer
  isr_count ++ ;

And somewhere in the code the interrupt was enabled:

  NVIC_EnableIRQ (ADC_IRQn) ;   // enable ADC interrupt vector
  ADC->ADC_IER = 0x80 ;         // enable AD7 End-Of-Conv interrupt (Arduino pin A0)

For other modules read the relevant chapter of the long-form datasheet...

Thank you.

So if I well understood: if I want to use the interrupts of the Digital-to-Analog Converter, I have to enable them with


and then write the corresponding interrupt routine in the DACC_Handler. Is it correct?

Are the Handlers special functions from Arduino? I mean, they don't exist if we use the Atmel uC alone.

You have all the source code and the datasheet - that's where to go for definitive information. In particular you need to study libsam as this contains lots of code you can call or adapt.