ESP32 Problem Interrupt I39 pin

marius.cezar18
Posts: 8
Joined: Mon May 16, 2022 10:41 am

ESP32 Problem Interrupt I39 pin

Postby marius.cezar18 » Thu Oct 20, 2022 6:17 am

Hello, I want use the interrupts on pins I35 and I39 and if turn on WiFi module intterupt on I39 pin it doesn't work properly, if turn off WiFi module working fine interrupt on I39 pin. So I found in esp32_errata_en.pdf "Section 3.11 for the detailed description of the issue" but I don t understand what tot do? Can you help-me, thanks!

Code: Select all

	#define GPIO_INPUT_WIEGAND_0     39//39
	#define GPIO_INPUT_WIEGAND_1     35//35
	
void InitInterrupts(){
	gpio_config_t io_conf = { };
	//interrupt of rising edge
	io_conf.intr_type = GPIO_INTR_DISABLE;	//GPIO_INTR_NEGEDGE
	//bit mask of the pins, use GPIO4/5 here
	io_conf.pin_bit_mask = (1ULL << GPIO_INPUT_WIEGAND_0);
	//set as input mode
	io_conf.mode = GPIO_MODE_INPUT;
	//enable pull-up mode
	io_conf.pull_down_en = 0;
	gpio_config(&io_conf);

	//interrupt of rising edge
	io_conf.intr_type = GPIO_INTR_DISABLE;	//GPIO_INTR_NEGEDGE
	//bit mask of the pins, use GPIO4/5 here
	io_conf.pin_bit_mask = (1ULL << GPIO_INPUT_WIEGAND_1);
	//set as input mode
	io_conf.mode = GPIO_MODE_INPUT;
	//enable pull-up mode
	io_conf.pull_down_en = 0;
	gpio_config(&io_conf);

	//create a queue to handle gpio event from isr
	gpio_evt_queue = xQueueCreate(40, sizeof(uint32_t));
	//start gpio task
	xTaskCreate(gpio_task_wiegand, "gpio_wiegand", 2048, NULL, 10,
			&TaskHandle_xtask_wiegand);


	//install gpio isr service
	gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
	//hook isr handler for specific gpio pin

	gpio_isr_handler_add(GPIO_INPUT_WIEGAND_1, gpio_isr_handler,
			(void*) GPIO_INPUT_WIEGAND_1);
	//hook isr handler for specific gpio pin
	gpio_isr_handler_add(GPIO_INPUT_WIEGAND_0, gpio_isr_handler,
			(void*) GPIO_INPUT_WIEGAND_0);

	gpio_set_intr_type(GPIO_NUM_39, GPIO_INTR_NEGEDGE);
	gpio_intr_enable(GPIO_NUM_39);
	gpio_set_intr_type(GPIO_NUM_35, GPIO_INTR_NEGEDGE);
	gpio_intr_enable(GPIO_NUM_35);
}

marius.cezar18
Posts: 8
Joined: Mon May 16, 2022 10:41 am

Re: ESP32 Problem Interrupt I39 pin

Postby marius.cezar18 » Fri Oct 21, 2022 5:32 am

I tried a workaround from the errata file (attached picture) but it has no effect, what could be wrong with my code?

Code: Select all

bool first_interrupt = 0;
static void IRAM_ATTR gpio_isr_handler(void *arg) {
	uint32_t gpio_num = (uint32_t) arg;
	if (!first_interrupt ) {//once
		first_interrupt = 1;
		gpio_set_intr_type(GPIO_INPUT_WIEGAND_0, GPIO_INTR_HIGH_LEVEL);
		gpio_set_intr_type(GPIO_INPUT_WIEGAND_1, GPIO_INTR_HIGH_LEVEL);
	} else {
		xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
	}
}

void InitInterrupts() {
	//zero-initialize the config structure.
//	esp_sleep_config_gpio_isolate();
//	rtc_gpio_deinit(GPIO_NUM_39);
//	rtc_gpio_deinit(GPIO_NUM_35);

	gpio_config_t io_conf = { };

	//interrupt of rising edge
	io_conf.intr_type = GPIO_INTR_LOW_LEVEL;	//GPIO_INTR_NEGEDGE
	//bit mask of the pins, use GPIO4/5 here
	io_conf.pin_bit_mask = (1ULL << GPIO_INPUT_WIEGAND_0);
	//set as input mode
	io_conf.mode = GPIO_MODE_INPUT;
	//enable pull-up mode
	io_conf.pull_down_en = 0;
	gpio_config(&io_conf);

	//interrupt of rising edge
	io_conf.intr_type = GPIO_INTR_LOW_LEVEL;	//GPIO_INTR_NEGEDGE
	//bit mask of the pins, use GPIO4/5 here
	io_conf.pin_bit_mask = (1ULL << GPIO_INPUT_WIEGAND_1);
	//set as input mode
	io_conf.mode = GPIO_MODE_INPUT;
	//enable pull-up mode
	io_conf.pull_down_en = 0;
	gpio_config(&io_conf);

	//create a queue to handle gpio event from isr
	gpio_evt_queue = xQueueCreate(40, sizeof(uint32_t));
	//start gpio task
	xTaskCreate(gpio_task_wiegand, "gpio_wiegand", 2048, NULL, 10,
			&TaskHandle_xtask_wiegand);

	//change gpio interrupt type for one pin
	gpio_set_intr_type(GPIO_INPUT_WIEGAND_0, GPIO_INTR_ANYEDGE);
	gpio_set_intr_type(GPIO_INPUT_WIEGAND_1, GPIO_INTR_ANYEDGE);

	//install gpio isr service
	gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
	//hook isr handler for specific gpio pin

	gpio_isr_handler_add(GPIO_INPUT_WIEGAND_1, gpio_isr_handler,
			(void*) GPIO_INPUT_WIEGAND_1);
	//hook isr handler for specific gpio pin
	gpio_isr_handler_add(GPIO_INPUT_WIEGAND_0, gpio_isr_handler,
			(void*) GPIO_INPUT_WIEGAND_0);
}
Attachments
trigger.png
trigger.png (165.4 KiB) Viewed 1638 times

Who is online

Users browsing this forum: No registered users and 92 guests