Hi,
FreeRTOS newbie here, I am using stm32 with whatever the STM32cubeide generates, so I’m using CMSIS v1.
My idea is that I have an UART Interrupt on Idle Callback, that sends the received array and its size to queue, which I then work in a “handler”-task.
So the handler task is just
" void uart_handler_task(void const *argument)
{
UART_Mail mail;
for (;;)
{
xQueueReceive(uart_RXHandle, &mail, portMAX_DELAY);
my_class_for_handling_msgs.some_func(mail);
}
}"
and the UART IDLE Callback looks like this
"
UART_Mail uart_isr_buff;
void HAL_UART_IDLE_Callback(UART_HandleTypeDef *huart)
{
__HAL_UART_DISABLE_IT(huart, UART_IT_IDLE);
uart_isr_buff.size = MAX_SIZE - __HAL_DMA_GET_COUNTER(huart->hdmarx);
portBASE_TYPE taskWoken = pdFALSE;
xQueueSendFromISR(uart_RXHandle, (void* ) &uart_isr_buff, &taskWoken);
portEND_SWITCHING_ISR(taskWoken);
HAL_UART_AbortReceive(huart);
__HAL_UART_CLEAR_IDLEFLAG(huart);
__HAL_UART_ENABLE_IT(huart, UART_IT_IDLE);
HAL_UART_Receive_DMA(huart, (uint8_t*) uart_isr_buff.arr, MAX_SIZE);
}
"
So it works pretty well, unless there are two messages coming really quick, then sometimes, but with a pretty high chance, I get a Hard Fault.
The stack looks like this, the last called function
Last position is
tasks.c-> void vListInsertEnd() ->"pxNewListItem->pxPrevious = pxIndex->pxPrevious;"
called from
tasks.c-> BaseType_t xTaskRemoveFromEventList()-> "prvAddTaskToReadyList(pxUnblockedTCB );"
called from
queue.c->BaseType_t xQueueGenericSendFromISR()->
"#else /* configUSE_QUEUE_SETS */
....
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )"
called from my callback on xQueueSendFromISR(uart_RXHandle, (void* ) &uart_isr_buff, &taskWoken);
I can’t really say what is happening here, and I’m not sure that the way I am executing the callback is right. some advice where should i look? Some priorities I might have set wrong?