How to use high priority interrupts
Posted: Thu Sep 17, 2020 10:12 am
Hello,
I seek help to use high priority interrupts.
I use a digital output from a ESP32(Pin 19), to trigger interrupts on 2 other ESP32s(Pin 23).
wire Connection is like,
This should mean that when ESP0 triggers a digital output, an interrupt is triggered on ESP1 and ESP2.
I do this twice and mark the time difference between the 2 interrupt arrives on ESP1 and ESP2.
I want this time to be the same on both ESP1 and ESP2 but in reality one of the ESP1(or ESP2) is always slower than the other by 2 to 10 micro seconds.
Here is the code for ESP1 and ESP2 interrupt creation.
Here is the code for interrupt handling
in Calc time task, I just print the time difference
1. Why is there a time difference in interrupt handling between the two ESPs although they are receiving the interrupts at the same time?
2. I have used ESP_INTR_FLAG_LEVEL3 while registering interrupt. If I try to use ESP_INTR_FLAG_LEVEL4 ESP_INTR_FLAG_LEVEL5 ESP_INTR_FLAG_LEVEL6 or ESP_INTR_FLAG_NMI , software crashes all the time. What should I do in order to use high prio interrupts like ESP_INTR_FLAG_NMI?
3. Will using high prio interrupts solve the problem with the time delays that I am facing now?
I seek help to use high priority interrupts.
I use a digital output from a ESP32(Pin 19), to trigger interrupts on 2 other ESP32s(Pin 23).
wire Connection is like,
This should mean that when ESP0 triggers a digital output, an interrupt is triggered on ESP1 and ESP2.
I do this twice and mark the time difference between the 2 interrupt arrives on ESP1 and ESP2.
I want this time to be the same on both ESP1 and ESP2 but in reality one of the ESP1(or ESP2) is always slower than the other by 2 to 10 micro seconds.
Here is the code for ESP1 and ESP2 interrupt creation.
Code: Select all
static void intr_create(void* pvParameter) {
gpio_pad_select_gpio(GPIO_NUM_23);
gpio_set_direction(GPIO_NUM_23, GPIO_MODE_INPUT);
gpio_pullup_en(GPIO_NUM_23);
gpio_pulldown_dis(GPIO_NUM_23);
gpio_set_intr_type(GPIO_NUM_23, GPIO_INTR_POSEDGE);
gpio_install_isr_service([b][i][u]ESP_INTR_FLAG_LEVEL3[/u][/i][/b]);
gpio_isr_handler_add(GPIO_NUM_23, zero_i_isr, (void*) GPIO_NUM_23);
gpio_intr_enable(GPIO_NUM_23);
Serial.printf("Interrupt setup \n");
vTaskDelete(NULL);
}
Code: Select all
static void IRAM_ATTR zero_i_isr(void *arg) {
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
static int j = 0;
j++;
time_test[j] = micros();
vTaskNotifyGiveFromISR(Calc_Time, &xHigherPriorityTaskWoken );
portYIELD_FROM_ISR();
}
in Calc time task, I just print the time difference
Code: Select all
if (j == 2) {
Serial.printf("Time between interrupts is %lu : %lu : %lu\n", time_test[2] - time_test[1], time_test[1], time_test[2]);
j = 0;
}
2. I have used ESP_INTR_FLAG_LEVEL3 while registering interrupt. If I try to use ESP_INTR_FLAG_LEVEL4 ESP_INTR_FLAG_LEVEL5 ESP_INTR_FLAG_LEVEL6 or ESP_INTR_FLAG_NMI , software crashes all the time. What should I do in order to use high prio interrupts like ESP_INTR_FLAG_NMI?
3. Will using high prio interrupts solve the problem with the time delays that I am facing now?