pinMode(DAC0,OUTPUT) error on Giga R1 Wifi Board

Using the Arduino Giga R1 Wifi board with two DAC's... DAC0 and DAC1...
I get this error...

"error: 'DAC0' was not declared in this scope
pinMode(DAC0, OUTPUT);"

When I try to compile and upload this code.

void setup() {
Serial.begin(9600);
pinMode(DAC0, OUTPUT);
}
void loop() {
analogWrite(DAC0, 2048);
delay(2000);
  }

I'm trying to output a steady state DC voltage (not PWM) from the onboard DAC on the Arduino Giga R1 Wifi but having no luck.

What am I doing wrong?

I've been trouble shooting this for over a week now with no luck so...

Thanks for any help.

1 Like

Does this help?

What board are you trying to compel this for?

And I think there is a limited range of the analog output:

These DAC pins have a default write resolution of 8-bits. This means that values that are written to the pin should be between 0-255.

Source is arduino docs..

In a different thread, someone indicated that analogWrite does not work on any of the DACs despite the documentation saying it should be possible (How to output constant DC voltage via onboard DAC's? - #8 by J-M-L). I also couldn't get analogWrite to work on a DAC on the Giga R1, so I ak using the Advanced Analog library instead.

Since there is apparently an analogWriteDAC function (https://github.com/arduino/ArduinoCore-mbed/blob/24138cc4b958d633ccb813d85fa1bab8a29f9693/cores/arduino/wiring_analog.cpp#L33) that should be triggered when calling analogWrite on a GIGA, it might be worth trying to call it directly and see what happens.

As for the pinMode statement: Try omitting it. I don't see why it would be necessary on dedicated DAC pins. Trying to leave it out doesnt cost you anything at least.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.