咨询一个关于esp32-s2-kaluga-1 的GPIO的问题,很奇怪
Posted: Tue Jan 18, 2022 3:46 am
用的是esp32-s2-kaluga-1.3版本,idf是4.3
代码基本就是demo generic gpio 裁剪的 代码如下:
#define GPIO_OUTPUT_IO_0 18
#define GPIO_OUTPUT_IO_1 19
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_OUTPUT_IO_0) | (1ULL<<GPIO_OUTPUT_IO_1))
void app_main(void)
{
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,e.g.GPIO18/19
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);
int cnt = 0;
while(1) {
printf("cnt: %d\n", cnt++);
vTaskDelay(1000 / portTICK_RATE_MS);
esp_err_t err=ESP_FAIL;
err=gpio_set_level(GPIO_OUTPUT_IO_0, 1);
printf("GPIO[%d] intr, val: %d Err:%d\n", GPIO_OUTPUT_IO_0, gpio_get_level(GPIO_OUTPUT_IO_0),err);
err=gpio_set_level(GPIO_OUTPUT_IO_1, cnt % 2);
printf("GPIO[%d] intr, val: %d Err:%d\n", GPIO_OUTPUT_IO_1, gpio_get_level(GPIO_OUTPUT_IO_1),err);
}
}
但是串口显示
[11:44:17.079] [0;32mI (250) cpu_start: Starting scheduler on PRO CPU.[0m
[11:44:17.079] [0;32mI (256) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
[11:44:17.095] [0;32mI (256) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
[11:44:17.095] cnt: 0
[11:44:17.095] GPIO[18] intr, val: 0 Err:0
[11:44:18.087] GPIO[19] intr, val: 0 Err:0
[11:44:18.087] cnt: 1
[11:44:18.087] GPIO[18] intr, val: 0 Err:0
[11:44:19.079] GPIO[19] intr, val: 0 Err:0
[11:44:19.079] cnt: 2
[11:44:19.095] GPIO[18] intr, val: 0 Err:0
[11:44:20.087] GPIO[19] intr, val: 0 Err:0
[11:44:20.087] cnt: 3
[11:44:20.087] GPIO[18] intr, val: 0 Err:0
[11:44:21.079] GPIO[19] intr, val: 0 Err:0
[11:44:21.079] cnt: 4
[11:44:21.095] GPIO[18] intr, val: 0 Err:0
[11:44:22.087] GPIO[19] intr, val: 0 Err:0
[11:44:22.087] cnt: 5
[11:44:22.087]
感觉代码没有什么问题,请问esp32-s2-kaluga-1 在使用GPIO的情况下有特别注意事项么
by the way
自带的camera的程序没有问题,就是想自定义gpio的时候不行,感觉是不是哪里没弄好
代码基本就是demo generic gpio 裁剪的 代码如下:
#define GPIO_OUTPUT_IO_0 18
#define GPIO_OUTPUT_IO_1 19
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_OUTPUT_IO_0) | (1ULL<<GPIO_OUTPUT_IO_1))
void app_main(void)
{
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,e.g.GPIO18/19
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);
int cnt = 0;
while(1) {
printf("cnt: %d\n", cnt++);
vTaskDelay(1000 / portTICK_RATE_MS);
esp_err_t err=ESP_FAIL;
err=gpio_set_level(GPIO_OUTPUT_IO_0, 1);
printf("GPIO[%d] intr, val: %d Err:%d\n", GPIO_OUTPUT_IO_0, gpio_get_level(GPIO_OUTPUT_IO_0),err);
err=gpio_set_level(GPIO_OUTPUT_IO_1, cnt % 2);
printf("GPIO[%d] intr, val: %d Err:%d\n", GPIO_OUTPUT_IO_1, gpio_get_level(GPIO_OUTPUT_IO_1),err);
}
}
但是串口显示
[11:44:17.079] [0;32mI (250) cpu_start: Starting scheduler on PRO CPU.[0m
[11:44:17.079] [0;32mI (256) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
[11:44:17.095] [0;32mI (256) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 [0m
[11:44:17.095] cnt: 0
[11:44:17.095] GPIO[18] intr, val: 0 Err:0
[11:44:18.087] GPIO[19] intr, val: 0 Err:0
[11:44:18.087] cnt: 1
[11:44:18.087] GPIO[18] intr, val: 0 Err:0
[11:44:19.079] GPIO[19] intr, val: 0 Err:0
[11:44:19.079] cnt: 2
[11:44:19.095] GPIO[18] intr, val: 0 Err:0
[11:44:20.087] GPIO[19] intr, val: 0 Err:0
[11:44:20.087] cnt: 3
[11:44:20.087] GPIO[18] intr, val: 0 Err:0
[11:44:21.079] GPIO[19] intr, val: 0 Err:0
[11:44:21.079] cnt: 4
[11:44:21.095] GPIO[18] intr, val: 0 Err:0
[11:44:22.087] GPIO[19] intr, val: 0 Err:0
[11:44:22.087] cnt: 5
[11:44:22.087]
感觉代码没有什么问题,请问esp32-s2-kaluga-1 在使用GPIO的情况下有特别注意事项么
by the way
自带的camera的程序没有问题,就是想自定义gpio的时候不行,感觉是不是哪里没弄好