GPIO_OUT_REG not updating

palmighty
Posts: 2
Joined: Fri Oct 23, 2020 2:18 pm

GPIO_OUT_REG not updating

Postby palmighty » Fri Oct 23, 2020 2:26 pm

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.

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: GPIO_OUT_REG not updating

Postby boarchuz » Sat Oct 24, 2020 12:04 am

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)

palmighty
Posts: 2
Joined: Fri Oct 23, 2020 2:18 pm

Re: GPIO_OUT_REG not updating

Postby palmighty » Sat Oct 24, 2020 8:39 pm

Aha! Got it working now, thanks!

Who is online

Users browsing this forum: Baidu [Spider], jhlee1 and 94 guests