ESP32 I2S Camera mode stops working if GPIO32 setup for output

toybuilder
Posts: 5
Joined: Thu Jan 31, 2019 6:02 pm

ESP32 I2S Camera mode stops working if GPIO32 setup for output

Postby toybuilder » Mon Aug 08, 2022 3:23 pm

I have discovered an unusual situation with my project which I think points to some kind of a bug, but I'm not sure what exactly.

I have a project which grabs raw grey-scale 8-bit data using https://github.com/espressif/esp32-camera, slightly modified to run on my particular hardware. The project works great, does what I want, and all is well... except I can't use GPIO32.

There are a six output bits that the project uses to control external hardware (Note 1). These outputs include GPIO32 and GPIO33. I set up the outputs using gpio_config:

Code: Select all


#define GPIO_OUTPUT_CHAN0  GPIO_NUM_25
#define GPIO_OUTPUT_CHAN1  GPIO_NUM_26
#define GPIO_OUTPUT_CHAN2  GPIO_NUM_27
#define GPIO_OUTPUT_GRP0   GPIO_NUM_13 // was GPIO32 but there seems to be a bug that we can't get around when GPIO32 is being used, which breaks the I2S camera mode
#define GPIO_OUTPUT_GRP1   GPIO_NUM_33
#define GPIO_OUTPUT_GRP2   GPIO_NUM_5
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_OUTPUT_CHAN0) | (1ULL<<GPIO_OUTPUT_CHAN1) | (1ULL<<GPIO_OUTPUT_CHAN2)  | (1ULL<<GPIO_OUTPUT_GRP0)  | (1ULL<<GPIO_OUTPUT_GRP1) |  (1ULL<<GPIO_OUTPUT_GRP2))

    //zero-initialize the config structure.
    gpio_config_t io_conf = {};
    //disable interrupt
    io_conf.intr_type = GPIO_INTR_DISABLE;
    //set as output mode
    io_conf.mode = GPIO_MODE_OUTPUT;
    //bit mask of the pins that you want to set
    io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
    //disable pull-down mode
    io_conf.pull_down_en = 0;
    //disable pull-up mode
    io_conf.pull_up_en = 0;
    //configure GPIO with the given settings
    gpio_config(&io_conf);
As you can see, I replaced GPIO32 with GPIO13 (and patched the PCB to match) and my project works perfectly well. However, when I was using GPIO32, the camera frame grabbing stopped working.

At first, I thought it maybe had to do with the use of GPIO32 and GPIO33 as gpio pins (there were some issues reported in the past (viewtopic.php?t=5058) (https://github.com/espressif/esp-idf/issues/285) about using GPIO32/33, but those issues appear to have been fixed years ago). Moreover, my problem isn't that GPIO32 and/or GPIO33 weren't working; rather setting up GPIO32 for GPIO output was breaking the I2S camera mode.

Note, too, that this is working fine with GPIO33 being used; so it does not appear to be related to the GPIOs being used being in the lower 32-bit registers (for GPIO00-GPIO31).

I didn't see anything in my dive through the IDF code for setting up GPIO that would suggest why I2S operation would be affected. I also reviewed my code and the code for the camera code and did not see anything to suggest that GPIO32 is used in some other way.

I do use GPIO34 to receive the VSYNC signal, which is used by the camera driver code to fire off an interrupts that controls the frame grabbing. These are the #define's for the signals used by the camera driver code:

Code: Select all

#define CAM_PIN_PWDN -1 // no powerdown
#define CAM_PIN_RESET -1 //software reset will be performed
#define CAM_PIN_XCLK -1 // no xclk - we don't generate the clock
#define CAM_PIN_SIOD -1 // no sccb
#define CAM_PIN_SIOC -1 // no sccb

#define CAM_PIN_D7 4
#define CAM_PIN_D6 16
#define CAM_PIN_D5 17
#define CAM_PIN_D4 18
#define CAM_PIN_D3 19
#define CAM_PIN_D2 21
#define CAM_PIN_D1 22
#define CAM_PIN_D0 23
#define CAM_PIN_VSYNC 34
#define CAM_PIN_HREF 35 // DE not HSYNC
#define CAM_PIN_PCLK 36
I checked the errata as well and do not see anything that seems to be relevant.

I am using IDF4.4. The ESP32 is on a ESP-WROOM-32 on a NodeMCU32S.

I'm not entirely sure where the best place to report this is. If the admins could kindly move this as needed, or suggest where else to post this or file an issue, I would be happy to do so.

Thank you.

Note 1: what these six output bits do should have no bearing on thte operation of the ESP32 -- they control a pair of 3:8 demux's to steer signals that come out of the ESP32.

Who is online

Users browsing this forum: No registered users and 22 guests