esp32c3 cannot control gpio21

Troy Mitchell
Posts: 16
Joined: Fri Aug 16, 2024 1:55 am

esp32c3 cannot control gpio21

Postby Troy Mitchell » Fri Aug 30, 2024 9:15 am

Chip: esp32c3 FN4

I set gpio21 to switch the level once every second, but in the end I only got a voltage of about 3v3 to 3v0.

I think the code is ok because I changed 21 to 11 (11 is connected to an led) and everything works fine.

Code:

```c
gpio_config_t cfg;
cfg.mode = GPIO_MODE_OUTPUT;
cfg.pull_up_en = GPIO_PULLUP_ENABLE;
cfg.pull_down_en = GPIO_PULLDOWN_ENABLE;
cfg.pin_bit_mask = 1ull << GPIO_NUM_21;
gpio_config(&cfg);

while (1) {
s_led_state = !s_led_state;
gpio_set_level(GPIO_NUM_11, s_led_state);
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
}
```

Troy Mitchell
Posts: 16
Joined: Fri Aug 16, 2024 1:55 am

Re: esp32c3 cannot control gpio21

Postby Troy Mitchell » Fri Aug 30, 2024 9:17 am

Troy Mitchell wrote:
Fri Aug 30, 2024 9:15 am
Chip: esp32c3 FN4

I set gpio21 to switch the level once every second, but in the end I only got a voltage of about 3v3 to 3v0.

I think the code is ok because I changed 21 to 11 (11 is connected to an led) and everything works fine.

Code:

```c
gpio_config_t cfg;
cfg.mode = GPIO_MODE_OUTPUT;
cfg.pull_up_en = GPIO_PULLUP_ENABLE;
cfg.pull_down_en = GPIO_PULLDOWN_ENABLE;
cfg.pin_bit_mask = 1ull << GPIO_NUM_21;
gpio_config(&cfg);

while (1) {
s_led_state = !s_led_state;
gpio_set_level(GPIO_NUM_11, s_led_state);
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
}
```
I don't think the gpio is affected by the member `pull_down_en`, bcs when I delete it , same thing.

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

Re: esp32c3 cannot control gpio21

Postby boarchuz » Fri Aug 30, 2024 11:00 am

gpio_config_t is not initialised

Also you config(21) and then set_level(11)

Troy Mitchell
Posts: 16
Joined: Fri Aug 16, 2024 1:55 am

Re: esp32c3 cannot control gpio21

Postby Troy Mitchell » Sat Aug 31, 2024 4:24 am

boarchuz wrote:
Fri Aug 30, 2024 11:00 am
gpio_config_t is not initialised

Also you config(21) and then set_level(11)
No, I just posted the wrong code, and I actually control 21.
I can see that the voltage jumps at 3 to 3.3v, and if I don't control 21, he won't jump.

Who is online

Users browsing this forum: Bing [Bot], markkuk and 324 guests