Hi David,
first of all, thank you for your answer! It definitely pointed me into the right direction. I have now tried to install an interrupt using the ETS_WIFI_MAC_INTR_SOURCE in the following fashion:
1.) I created a freeRTOS Event group to handle some events of my SyncTSF service. The only thing the interrupt is supposed to do at the moment is to set an event bit when it's triggered, which will then in turn signal the event handler to print a message on the console. Here is how I create the task:
Code: Select all
void syncTSF_init(void){
syncTSF_event_group = xEventGroupCreate();
syncTSF_event_group_mutex = xSemaphoreCreateMutex();
xTaskCreatePinnedToCore(&syncTSF,
"SyncTSF",
2048,
&syncTSF_interrupt_handle,
4,
syncTSF_task,
0);
}
2.) The interrupt is allocated and started within that same task if the SyncTSF start function sets the dedicated bit. In that way I make sure the interrupt is created on the same core the task is running. The code of this specific section looks like this:
Code: Select all
static void syncTSF(void *pvParameters){
const EventBits_t xBitsToWaitFor = ( SYNC_TSF_STARTED | SYNC_TSF_STOPPED | SYNC_TSF_WIFI_PROBE_RCVD );
EventBits_t xEventGroupValue;
const TickType_t xTicksToWait = 200 / portTICK_PERIOD_MS;
for(;;){
xEventGroupValue = xEventGroupWaitBits(syncTSF_event_group, xBitsToWaitFor, pdFALSE, pdFALSE, xTicksToWait);
/* Print the Event Bits for debugging */
ESP_LOGI(TAG, "Event Bits value: %d", (uint32_t) xEventGroupValue);
/* This is where the message gets printed in case the interrupt handler sets the SYNC_TSF_WIFI_PROBE_RCVD Bit */
if((xEventGroupValue & ( SYNC_TSF_RUNNING | SYNC_TSF_WIFI_PROBE_RCVD )) ==
( SYNC_TSF_RUNNING | SYNC_TSF_WIFI_PROBE_RCVD )){
ESP_LOGI(TAG, "Interupt triggered");
}
}
else if((xEventGroupValue & SYNC_TSF_STARTED) && syncTSF_intr_handle == NULL){
ESP_LOGI(TAG, "SyncTSF Service Started");
/* Allocate Interrupt */
esp_intr_alloc( ETS_WIFI_MAC_INTR_SOURCE,
ESP_INTR_FLAG_SHARED,
&syncTSF_interrupt_handle,
NULL,
&syncTSF_intr_handle);
/* Set the Service in running state */
xEventGroupSetBits(syncTSF_event_group, SYNC_TSF_RUNNING);
xEventGroupClearBits(syncTSF_event_group, SYNC_TSF_STARTED);
esp_intr_enable(syncTSF_intr_handle);
}
}
}
3.) Finally, as I said, the interrupt handler which sets the SYNC_TSF_WIFI_PROBE_RCVD Bit to trigger the Event:
Code: Select all
void syncTSF_interrupt_handle(void *arg){
xEventGroupClearBitsFromISR(syncTSF_event_group, SYNC_TSF_WIFI_PROBE_RCVD);
}
4.) Now, when I do everything as described, I immediately get a core panic with the following message after the interrupt is entered for the first time:
Code: Select all
␛[0;32mI (3153) SyncTSF: Event Bits value: 2␛[0m
␛[0;32mI (3163) SyncTSF: SyncTSF Service Started␛[0m
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
This only happens when I create my event handler task on core 0. If I try to create it on core 1, the interrupt handler is never entered. I also tried to increase the watchdog timeout value, but that didn't help either. When I try the functions provided in the
rom/ets_sys.h library, it has the same effect (nothing happens basically == the interrupt is either never entered or not created at all). I know that what I'm doing isn't thread safe but that shouldn't be the reason for the core panic. Since this interrupt source is probably used also by the WiFi PHY driver, could that be the reason for this kind of behavior? What am I missing here?