Page 1 of 1

Unable to toggle esp32 c6 GPIO_NUM_4

Posted: Wed Feb 21, 2024 8:40 am
by sauravkumal
Hi, I am not sure why i am unable to toggle esp32 c6 GPIO_4. I am able to toggle GPIO_5. Same code works for esp32.

But for GPIO_4 its always low. Does this pin require special configuration? I looked throughout the documentation and didn't find such case.
  1. #include <stdio.h>
  2.  
  3. #include "esp_log.h"
  4.  
  5. #include "lvgl.h"
  6. #include "freertos/FreeRTOS.h"
  7. #include "freertos/task.h"
  8. #include "driver/gpio.h"
  9.  
  10. static const char *TAG = "WATCH";
  11. static bool state;
  12.  
  13. void app_main(void)
  14. {
  15.     ESP_LOGD(TAG, "Start Main");
  16.  
  17.     gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
  18.     gpio_set_level(GPIO_NUM_4, 1);
  19.     state = false;
  20.  
  21.     while (true)
  22.     {
  23.         if (state == true)
  24.         {
  25.             gpio_set_level(GPIO_NUM_4, 0);
  26.             state = false;
  27.             ESP_LOGD(TAG, "Motor off");
  28.         }
  29.         else
  30.         {
  31.             state = true;
  32.             gpio_set_level(GPIO_NUM_4, 1);
  33.             ESP_LOGD(TAG, "Motor on");
  34.         }
  35.        
  36.         vTaskDelay(pdMS_TO_TICKS(1000));
  37.     }
  38. }

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Posted: Mon Feb 26, 2024 9:41 pm
by JoeSensoric
Which board are you using? Do you have a schematic?
Perhaps there is something connected to GPIO4 onboard.

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Posted: Fri May 10, 2024 9:59 pm
by sauravkumal
I am now using esp32 c6 wroom-1 dev board without connecting anything. Still not working.

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Posted: Sun May 12, 2024 8:48 am
by JoeSensoric
In the datasheet GPIO4 and 5 (and others) are highlighted with reference to chapter "2.3.4 Restrictions for GPIOs and LP GPIOs".
Both GPIOs are used for SPI and are "input enabled" at boot time and after.
The non-highlighted GPIO or LP GPIO pins are recommended for use first.
This should not interfere with your program...

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Posted: Mon Jun 17, 2024 4:49 pm
by skwidder
I'm having this same issue as well as being unable to set the Pin as a UART. Did anyone find a solution to this issue?