Unable to toggle esp32 c6 GPIO_NUM_4

sauravkumal
Posts: 2
Joined: Wed Feb 21, 2024 8:33 am

Unable to toggle esp32 c6 GPIO_NUM_4

Postby sauravkumal » Wed Feb 21, 2024 8:40 am

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. }

JoeSensoric
Posts: 28
Joined: Fri Mar 03, 2017 10:31 am

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Postby JoeSensoric » Mon Feb 26, 2024 9:41 pm

Which board are you using? Do you have a schematic?
Perhaps there is something connected to GPIO4 onboard.

sauravkumal
Posts: 2
Joined: Wed Feb 21, 2024 8:33 am

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Postby sauravkumal » Fri May 10, 2024 9:59 pm

I am now using esp32 c6 wroom-1 dev board without connecting anything. Still not working.

JoeSensoric
Posts: 28
Joined: Fri Mar 03, 2017 10:31 am

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Postby JoeSensoric » Sun May 12, 2024 8:48 am

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...

skwidder
Posts: 1
Joined: Mon Jun 17, 2024 4:42 pm

Re: Unable to toggle esp32 c6 GPIO_NUM_4

Postby skwidder » Mon Jun 17, 2024 4:49 pm

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?

Who is online

Users browsing this forum: Bing [Bot], derricksenva, Google [Bot] and 221 guests