Page 1 of 1

GPIO_OUT_REG not updating

Posted: Fri Oct 23, 2020 2:26 pm
by palmighty
Hi, I just started figuring out the esp32, and by the technical docs, GPIO_OUT_REG should be a R/W register indicating current pin status. However after a simple test:

Code: Select all

void setup() {
  Serial.begin(115200);

  REG_WRITE(GPIO_ENABLE_REG, BIT4);

}

void loop() {

  REG_WRITE(GPIO_OUT_REG,BIT4);
  delay(500);
  Serial.println(GPIO_OUT_REG, BIN);
  REG_WRITE(GPIO_OUT_REG,0x00000000);
  delay(500);
  Serial.println(GPIO_OUT_REG, BIN);
  
}
This is the serial monitor result for one loop:

Code: Select all

111111111101000100000000000100
111111111101000100000000000100
Even though I changed the register, and the test LED does blink, when I read it back the register doesn't change, as if I never even set BIT4.
I know that it's a better alternative to use the W1TS/C registers, but I wanted to check the functionality of this register as well.

Re: GPIO_OUT_REG not updating

Posted: Sat Oct 24, 2020 12:04 am
by boarchuz

Code: Select all

Serial.println(GPIO_OUT_REG, BIN);
You are printing GPIO_OUT_REG, defined as 0x3f404004, not the current value in that register. Try REG_READ(GPIO_OUT_REG)

Re: GPIO_OUT_REG not updating

Posted: Sat Oct 24, 2020 8:39 pm
by palmighty
Aha! Got it working now, thanks!