Using Trinket M0 DAC in Arduino IDE.

Adafruit's tiny microcontroller platform. 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
Stolk
 
Posts: 19
Joined: Sat Oct 30, 2021 11:10 am

Using Trinket M0 DAC in Arduino IDE.

Post by Stolk »

Hello,

My first post here, I look forward to joining this amazing community. I think Lady Ada is a star, kick-starting an electronics empire from an MIT dorm-room... how kick-ass is that?

Anyways:
I have a 3.3V Trinket M0 that I am programming with the Arduino IDE.

From the docs, I understand that Trinket M0 has a 10 bit DAC.

So to set up, I do:

Code: Select all

// the setup function runs once when you press reset or power the board
void setup()
{
  pinMode(PIN_A0, OUTPUT);
  analogWriteResolution(10);
  while (!Serial) ; // Wait for serial port to become ready.
  Serial.println("Trinket M0 is ready.");
}
And because the highest 10 bit number is 0x3ff, I alternately write 0x00 and 0x3ff to the pin, at 0.5 Hertz, like so:

Code: Select all

// the loop function runs over and over again forever
void loop() 
{
  static int cnt=0;
  cnt += 1;
  analogWrite( PIN_A0, (cnt&1) ? 0x3ff : 0x000 );
  delay(2000);
}
To my surprise, when I measure at pin A0 on my tricket, with my volt-meter, I see two values (as expected)

* 0.0V
* 2.2V

I did not expect to see 2.2V. When I write the max analog value to A0, should I not see 3.3V instead?

The 2.2V is not enough to trigger my mosfet gate, that I have in my circuit, and I don't understand why A0 cannot output 3.3 volts.

Thanks!

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

Return to “Trinket ATTiny, Trinket M0”