Code: Select all
static void IRAM_ATTR gpio_interrupt_handler(void *args)
{
int pinNumber = (int)args;
start = esp_timer_get_time();
xQueueSendFromISR(interputQueue, &pinNumber, NULL);
}
void isr_task(void *params)
{
int pinNumber;
while(1)
{
if (xQueueReceive(interputQueue, &pinNumber, portMAX_DELAY))
{
stop = esp_timer_get_time();
printf("interrupt delay %llu us\n", (stop - start));
}
}
}
void app_main(void)
{
...
gpio_pad_select_gpio(35);
gpio_set_direction(35, GPIO_MODE_INPUT);
gpio_set_intr_type(35, GPIO_INTR_POSEDGE);
interputQueue = xQueueCreate(10, sizeof(int));
xTaskCreate(isr_task, "isr_task", 2048, NULL, 20, NULL); //configMAX_PRIORITIES = 25
gpio_install_isr_service(ESP_INTR_FLAG_LEVEL3);
gpio_isr_handler_add(35, gpio_interrupt_handler, (void *)35);
...
}
interrupt delay 4715 us
interrupt delay 2185 us
interrupt delay 4916 us
interrupt delay 15 us
interrupt delay 1237 us
interrupt delay 2562 us
interrupt delay 2592 us
interrupt delay 3882 us
interrupt delay 204 us
interrupt delay 1758 us
interrupt delay 1557 us
interrupt delay 2053 us
interrupt delay 4593 us
interrupt delay 2849 us
interrupt delay 4201 us
interrupt delay 522 us
interrupt delay 3770 us
interrupt delay 1813 us
interrupt delay 3167 us
interrupt delay 4091 us
interrupt delay 1657 us
interrupt delay 4457 us
interrupt delay 779 us
interrupt delay 2133 us
interrupt delay 750 us
interrupt delay 2752 us
interrupt delay 3423 us
I would like a delay no more than a millisecond. I will be glad to any advice. Thank you.