I want to have a SPI traffic between an ESP32 slave and a PIC-MCU master. The SPI interface is working as well in case I start the transfer in the main.c. But the traffic procedure is asynchron, so the ESP-SPI must wait until the transfer ist finalized by the master. For this I have to start the ESP slave spi transfer with "portMAX_DELAY". This is blocking the further process. So I decide to create separate task for the SPI slave transfer.
Code: Select all
.........
TaskHandle_t Se_Re_SPI_Task = NULL;
ReadyForSPItrans = false;
WaitForSPIresp = false;
xTaskCreate(Send_Rec_SPI, "Send_Rec_SPI", 1024, &SPItransmit, 1,
&Se_Re_SPI_Task);
configASSERT(Se_Re_SPI_Task);
.........
Code: Select all
void Send_Rec_SPI(void *AdrToSPIdef) //own Task
{
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
printf("\nTask added to TWDT\n");
while(1)
{
vTaskDelay(3000 / portTICK_PERIOD_MS); //just for test
if (ReadyForSPItrans) //spi slave is ready for transfer, trigger-GPIO for PIC is active, wait for
master-pickup
{
spi_slave_transmit(RCV_HOST, AdrToSPIdef, portMAX_DELAY);
ReadyForSPItrans = false; // handshake
WaitForSPIresp = true; // handshake
printf("\nSPI transmit started\n");
}
ESP_ERROR_CHECK(esp_task_wdt_reset()); //without effect because "portMAX_DELAY" is blocking the task, in case
"spi_slave_transmit" is started
printf("\nTWDT Resetted\n");
if (WaitForSPIresp == true) printf("\nWait for resp is true\n");;
}
}
My question is:E (30538) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (30538) task_wdt: - Send_Rec_SPI (CPU 0/1)
E (30538) task_wdt: Tasks currently running:
E (30538) task_wdt: CPU 0: IDLE0
E (30538) task_wdt: CPU 1: IDLE1
E (30538) task_wdt: Print CPU 0 (current core) backtrace
Backtrace: 0x400DB6C6:0x3FFB2280 0x400DBA8C:0x3FFB22A0 0x40082F79:0x3FFB22D0 0x40087983:0x3FFBBB70 0x401687FA:0x3FFBBB90 0x4008ADA5:0x3FFBBBB0 0x40089D29:0x3FFBBBD0
--- 0x400db6c6: task_wdt_timeout_handling at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_system/task_wdt/task_wdt.c:436
--- 0x400dba8c: task_wdt_isr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_system/task_wdt/task_wdt.c:509
--- 0x40082f79: _xt_lowint1 at C:/Espressif/frameworks/esp-idf-v5.5.2/components/xtensa/xtensa_vectors.S:1240
--- 0x40087983: xt_utils_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/xtensa/include/xt_utils.h:82
--- (inlined by) esp_cpu_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_hw_support/cpu.c:55
--- 0x401687fa: esp_vApplicationIdleHook at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_system/freertos_hooks.c:58
--- 0x4008ada5: prvIdleTask at C:/Espressif/frameworks/esp-idf-v5.5.2/components/freertos/FreeRTOS-Kernel/tasks.c:4350
--- 0x40089d29: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.5.2/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139
E (30538) task_wdt: Print CPU 1 backtrace
Backtrace: 0x40084076:0x3FFB2AE0 0x40082F79:0x3FFB2B00 0x40087983:0x3FFBC180 0x401687FA:0x3FFBC1A0 0x4008ADA5:0x3FFBC1C0 0x40089D29:0x3FFBC1E0
--- 0x40084076: esp_crosscore_isr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_system/crosscore_int.c:74
--- 0x40082f79: _xt_lowint1 at C:/Espressif/frameworks/esp-idf-v5.5.2/components/xtensa/xtensa_vectors.S:1240
--- 0x40087983: xt_utils_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/xtensa/include/xt_utils.h:82
--- (inlined by) esp_cpu_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_hw_support/cpu.c:55
--- 0x401687fa: esp_vApplicationIdleHook
at C:/Espressif/frameworks/esp-idf-v5.5.2/components/esp_system/freertos_hooks.c:58
--- 0x4008ada5: prvIdleTask at C:/Espressif/frameworks/esp-idf-v5.5.2/components/freertos/FreeRTOS-Kernel/tasks.c:4350
--- 0x40089d29: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.5.2/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139
- why it is working in the main.c without the error message
- what I have to do, that the behavior of "spi_slave_transmit" in the task "Send_Rec_SPI" is the same as in the "main".
Thank you for the support.
Henry