xQueueSendToBackFromISR causes Interrupt watchdog timeout
Posted: Thu Nov 02, 2023 2:09 am
I have a custom ISR for UART:
And in another component, the function to receive characters and decode, using a local static struct for buffered characters and state. "MessageAddChr" is pretty simple and fast, and does some byte checking and manipulation to check for valid messages. Not shown here, for brevity. The MsgT struct is about 60 bytes:
This works fine if I comment out the line "xQueueSendToBackFromISR(...)"
However, if I enable the line, the code hangs and then reboots with an interrupt watchdog timeout error:
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
It looks like writing to the queue is blocking the function and thus the ISR. Why would "xQueueSendToBackFromISR" cause this code to hang? Note I have another task which is reading the messages from the queue, but I don't know why that would make a difference.
We are using ESP-IDF v4.4.4.
Code: Select all
static void IRAM_ATTR uart_isr_handler(void* arg)
{
(void)(arg); // Unused
uint16_t bytes_available = UART1.status.rxfifo_cnt;
for (uint16_t i = 0; i < bytes_available; i++)
{
uint8_t data = (uint8_t)UART1.fifo.rw_byte;
MessagesHandleReceivedByteISR(data);
}
// Clear interrupt flags:
uart_clear_intr_status(UART_NUM_1, UART_RXFIFO_FULL_INT_CLR | UART_RXFIFO_TOUT_INT_CLR);
}
Code: Select all
typedef struct
{
uint8_t len;
bool msg_on_hold;
uint8_t buffer[BUFFER_SIZE],
//... Etc.
} MsgT;
static MsgT l_incoming_message;
void MessagesHandleReceivedByteISR(uint8_t data)
{
XpRxResultT result = MessageAddChr(&l_incoming_message, data);
// Sets "msg_on_hold" to true when a complete message has been received and decoded.
if (!l_incoming_message.msg_on_hold) return;
BaseType_t higher_priority_task_woken = pdFALSE;
xQueueSendToBackFromISR(l_rx_queue, &l_incoming_message, &higher_priority_task_woken);
(void)(higher_priority_task_woken); // Unused, for now.
MessageInit(&l_incoming_message); // Reset the message struct.
}
However, if I enable the line, the code hangs and then reboots with an interrupt watchdog timeout error:
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
It looks like writing to the queue is blocking the function and thus the ISR. Why would "xQueueSendToBackFromISR" cause this code to hang? Note I have another task which is reading the messages from the queue, but I don't know why that would make a difference.
We are using ESP-IDF v4.4.4.