Set ref for DAC [Solved]

// Analog Out on Pin A0
// pinMode(A0, OUTPUT);       // Not declare that it will not work
  analogReference(AR_INTERNAL1V0);
  analogWriteResolution(10);  // Change the DAC resolution to 10-bits
  analogWrite(A0, 0);         // Initialize Dac  to Zero

Also declaring analogReference, Out also is 3.3V
How to set to precise 1V ?

Hi Giorgio,

analogReference(AR_INTERNAL1V0);

This is for the ADC reference and not the DAC.

As far as I know there is not an api to set the DAC reference in the Arduino IDE, but you can do it using register manipulation.
Add this in the setup:

DAC->CTRLB.bit.REFSEL = 0;

and the DAC reference will be set to the internal 1V.

See page 922 in the SAMD21 datasheet

Marco