Using other Vref for DAC on itsybitsy M0 Express

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
feather_user
 
Posts: 3
Joined: Wed Oct 10, 2018 12:18 pm

Using other Vref for DAC on itsybitsy M0 Express

Post by feather_user »

I'm playing around with the ItsyBitsy M0, and specifically trying to play around with other Voltage references for the DAC other than the standard 3.3V reference. Do the Arduino analog functions have support for other references or do I need to dig deeper into the SAMD documentation and set bits manually? Anyone have experience with this?

For reference, here's what I'm currently using:

Code: Select all

  #define DAC_PIN A0

  // adafruit docs say to not set the A0 pin to output if used as a true DAC
  //pinMode(DAC_PIN, OUTPUT);
  analogWriteResolution(10);
  analogReference(AR_INTERNAL1V0);

  analogWrite(DAC_PIN, output);
I needed to add the call to analogWriteResolution to get the full 10 bit range of the DAC, but the reference call doesn't appear to work right away. The AR_INTERNAL1V0 comes from the wiring analog header file, but that header seems to mostly be referencing the ADC and not the DAC.

I'm succesful in outputting from the DAC across the 3.3V range, but would like to use a different reference if it's not too much effort. Has anyone implemented this on the itsybitsy M0 or other SAMD21 boards using the arduino libraries?

User avatar
feather_user
 
Posts: 3
Joined: Wed Oct 10, 2018 12:18 pm

Re: Using other Vref for DAC on itsybitsy M0 Express

Post by feather_user »

Started reading the Atmel docs and decided to do one more google and it seems I'm not the first to try to do this. Arduino forum to the rescue:
https://forum.arduino.cc/t/set-ref-for- ... ved/628586

In case that post doesn't survive the passage of internet time, here's the trick:

analogReference(AR_INTERNAL1V0) only works for the ADC

the DAC voltage reference can be set directly:

Code: Select all

DAC->CTRLB.bit.REFSEL = 0;
Page 922 of the docs shows the options for the DAC voltage reference settings.
https://cdn.sparkfun.com/datasheets/Dev ... asheet.pdf

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”