Disable DAC Pins on Pin 25 and 26 on ESP32


I have made a custom board and everything is working perfectly. However, there are two pins GPIO25 and GPIO26 which are connected to external interrupts. They are not working. Later I removed all connections and found that these two pins are DAC pins and by default they output ~2v. I am using Arduino environment.

Can someone please suggest how to disable DAC and convert them to GPIO? Below is a simple blink LED sketch. However, the output on the pins is always 1.9v whether the pin status is set to high or low.

#define PIN1 26
#define PIN2 25

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(PIN1, OUTPUT);
  pinMode(PIN2, OUTPUT);

// the loop function runs over and over again forever
void loop() {
  digitalWrite(PIN1, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(PIN2, LOW);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second
  digitalWrite(PIN1, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(PIN2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second

No. They're internally configured so.
The design structure is composed of integrated resistor strings and a buffer. This dual DAC supports power supply as input voltage reference.

I have other development boards on which I can control the pins 25 and pins 26. On the custom board, I cannot configure it. When I try writing dacWrite(25, 0) or dacWrite(25,255), the output voltage will be 0.1v and 3.28v accordingly. This means the pins are working correctly. However, I cannot set them as GPIO's.

This is the new lot purchased from digikey and not sure if they have any changes done in the firmware. In any case, is there a function available where I can disable dac and configure them as GPIO's?

Also, one of the answers on Espressif forum suggested another user to disable the same. However, not mentioned how it is done

When ESP32 Core, will be set GPIOMUX correctly at pinMode.
It's strange that the DAC isn't disabled.
I have multiple lots of ESP32 now and the GPIO is setup correctly in pinMode...
What if you manually set the MUX from RTC to GPIO?

Can you please confirm how do I do it in Arduino? All other pins are configured correctly.

Test this.
My ESP32 works fine.

void setup() {
    pinMode(25, OUTPUT);
    pinMode(26, OUTPUT);
    // It has been replaced by below.
  ESP_REG(0x3FF44024) = (uint32_t)0x6000000;
  ESP_REG(0x3FF48484) = (uint32_t)0xC0000800;
  ESP_REG(0x3FF48488) = (uint32_t)0xC0000800;
  ESP_REG(0x3FF49024) = (uint32_t)0x2E00;
  ESP_REG(0x3FF49028) = (uint32_t)0x2E00;

void loop() {
  digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level)
  digitalWrite(26, LOW);  // turn the LED on (HIGH is the voltage level)
  delay(3000);            // wait for a second
  digitalWrite(25, LOW);  // turn the LED off by making the voltage LOW
  digitalWrite(26, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(3000);            // wait for a second

Thanks for the suggestion. However, this is not working. It still says 1.9v. Can you please confirm what is this trying to do? I need to know if there are any registers that disable DAC in ESP32?

If you know the what is register, please check the register map by yourself in the reference manual.
Open documents, and into serach window my code's adress.

By the way, that code also sets the DAC1/2 register.
In addition to disabling it, 0 is also written to the DAC value.
In other words, Whether the DAC is alive or not, something is wrong there is still voltage on the output.

ESP_REG(0x3FF48484) = (uint32_t)0xC0000800;

1 Like

In addition, I've tried with three board of ESP32 I have.

  1. First I had fun with pinMode(25, ANALOG) and dacWrite(25, xxx).
  2. Yeah, sounds good. :relaxed:
  3. After few delay() I put the code I posted and digitalWrite() loops.
  4. They back to working properly with digitalWrite(). :wink:

Sorry, I don't know the other things.
Because it can't be reenact situation in own ESP32 at all. :pensive:

Well. I guess it should be a bad module. I will solder another esp32 module on another PCB and recheck.

Even then, I learnt a lot of stuff from your suggestion. One weird thing is when I write a voltage to pin 25 (dacWrite), pin 26 reflects same voltage. For example, if I write 125 to pin 25 and 255 to pin 26, both the pins output 1.6v. so, whatever voltage is fed, same voltage on both pins.

Something is wrong with the module I guess.

Thank you.

If possible, please report the results after doing that.
It good rewards my suggestion. :relaxed:

Sure. Will report on this thread... Maybe in a day or two. Too many smd components, takes time to solder manually.

1 Like


Found the solution as below:

// Disable DAC1
// Disable DAC2
1 Like

Hi, Congrats to find solution. :blush:

However, the "FORCE" bit set to 1 is even should be DAC Power, so it's quite mysterious.
The DAC should be able to be disabled without set such a register state, and so is pinMode() function implementation.


This also seems a mystery to me... :thinking:
But doesn't use DAC to your project, so I don't think it's problem. Maybe.

Good work them. :+1:

I am not sure on the register setting, but I can assure that it is working on blinking LED as well as interrupts. However, the only change is I need to explicitly set Pinmode to input to make interrupts work. Though it may not be a problem, I thought I will share that.

Regarding the second mystery, I am still not sure why it so happens.