Go Down

Topic: Set ref for DAC [Solved] (Read 1 time) previous topic - next topic

x-giorgio-x

Dec 30, 2019, 05:38 pm Last Edit: Jan 03, 2020, 10:06 am by x-giorgio-x
Code: [Select]

// 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 ?

Sulimarco

Hi Giorgio,

Quote
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

Go Up