Arduino Due DAC0 don't work

Hello everyone,

I’m using Arduino DUE (Sam3X8E) for data acquisition trough ADC converter, I need set two voltages values in DAC0 and DAC1 outputs.
When I try this code yesterday:

void setup() 

void loop() 
  analogWrite(DAC0, 3150);  // DAC0=2.25V
  analogWrite(DAC1, 3150);  // DAC1=2.25V
  analogWrite(DAC0, 0);  // DAC0=0.55V

  analogWrite(DAC1, 0);  // DAC1=0.55V

it worked fine (I measure analog output DAC0 and DAC1 with voltmeter, these were well), but now suddenly DAC0 always put values around 0 to the output (-0.007V ~ 0.026V) :astonished: however DAC1 works fine.

I’m using arduino-1.5.6-r2 and I read this interesting post about similar error: therefore I test top code wit arduino-1.5.7 version with same result, DAC0 doesn’t work fine.

I don’t know how apply this path to my analogWrite() function in the wiring library maybe it was applied already at arduino-1.5.7 version.

Someone have or have had a similar problem?

Any idea or suggestion that might be happening and how to fix it?

Thanks and sorry for mistakes in my English.

This sounds like another instance of this problem:

Remember the Due pins cannot drive nearly as much current as the Uno/Mega pins,
some are limited to 3mA absolute maximum(*). Perhaps you overloaded the DAC0
pin somehow?

(*) The datasheet lists the limits in detail if you can find the right section.

Hello MarkT!,

Thanks for your reply.

I haven't put values over 4095 to analogwrite() function ever so that I can't overload DAC0.

How can I put more than 3 mA in the output?, I don´t know do that.

How can I test DAC0 for know if it's hardware error or logical error?? (if the DAC0 register was corrupted...)

Thanks again, any help or comment about this will be appreciated, I don't know I can do now.

You may check the content of registers, see if anything out of order, and compare channels 1 & 2.

       unsigned long reg;
       reg = REG_DACC_MR;
       Serial.print("\n\tREG_DACC_MR = ");
       Serial.println(reg, HEX);   
       reg = REG_DACC_CHSR;
       Serial.print("\n\tREG_DACC_CHSR = ");
       Serial.println(reg, HEX);      

       reg = REG_DACC_ACR;
       Serial.print("\n\tREG_DACC_ACR = ");
       Serial.println(reg, HEX);

There are some more, less important, look in the sketch.

DAC_SW_reset_test_1a.ino (8.83 KB)

If you read the thread you'll see that DAC0 in particular is shared with other functions
on the chip, notable WKUP12, one of the wake-up pins, it is conjectured this is something
to do with the apparent fragility of the DAC0 pin (compared to any of the others).

Anti-static precautions are necessary with all CMOS devices, the Due will be much less
robust than the Uno since the process used has thinner gate oxide and handles smaller
currents and all the transistors are far smaller than in ATmega chips. Its not emphasized
enough on these forums that these devices are delicate to static even with the built-in
protection diodes.

My anti-static precautions are wear cotton only, live in a damp climate... Seriously
avoid nylon carpets and clothing!

Note that the WKUP pins may not have all the protection diodes of other pins as they have
to be able to go HIGH while some internal circuitry is powered down - hence likely to be more fragile. Well, that's the theory.

In general handling electronics you want to place your body at the same potential as the
board before touching any input/output lines. So pick up a board carefully, touching the
grounded USB connectors first if you have any suspicion you might have some static charge.

Having a conducive grounded work surface is great because you ground yourself
to it as soon as you rest your arms. Conducive does not mean conductive, it needs to
leak away static charge without shorting out circuitry. Wood is a fine material for
this use.

I'm not sure if the SAM3X even has protection diodes. I think there's only on die termination of 39 ohm to reduce ringing and EMI. Note the 3.6V DC maximum input voltage ... a tight limit to follow during experimentation and testing, however I don't think there's any code you could use that would damage DAC0.

Normally all CMOS pins have protection unless they are 5V tolerant or
open-drain or line-receivers.