jiricharvat wrote on Monday, June 15, 2015:
Hello,
I would like to use FreeRTOS queues for sending messages between USB Isr() and Rtos Task. But the queues do not seem to work - at higher speeds/volumes the data seems to be inconsistent or corrupted. Namely assert configASSERT(cmd->m_type == UNDEF_CMD) fails.
Interrupt routine is using GetFreeCommandFromISR() and HandleCommandFromISR():
<a href="#">
struct sCmd\* GetFreeCommandFromISR()
{
struct sCmd\* cmd;
BaseType_t res = xQueueReceiveFromISR( coreFreeCmd, &cmd, NULL );
configASSERT(res == pdPASS);
configASSERT(cmd->m_type == UNDEF_CMD);
return cmd;
}
//Now the interrupt routine fills data received via USB into sCmd structure and
//enqueues it into coreQueue for processing in Rtos task
void HandleCommandFromISR(struct sCmd\* c)
{
BaseType_t res = xQueueSendToBackFromISR( coreQueue, &c, 0U );
configASSERT(res == pdPASS);
}
The RTOS task is using this main loop:
for( ;; )
{
/* Wait until something arrives in the queue - this task will block */
while(pdPASS == xQueueReceive( coreQueue, &cmd, portMAX_DELAY ) )
{
/* ProcessCoreTaskCommand */
ProcessCoreCommand(cmd);
BaseType_t res;
do {
struct sCmd\* cmd2 = cmd;
cmd2->m_type = UNDEF_CMD;
res = xQueueSend( coreFreeCmd, &cmd2, 0U );
} while(res != pdPASS);
}
}
</a>
Hardware: SmartFusion2 StarterKit, SoftConsoleIDE 3.4
FreeRTOS: 8.2.1 (having the same with 8.1.2)
I have a full demo of this using FreeRTOSV8.2.1\FreeRTOS\Demo\CORTEX_SmartFusion2_M2S050_SoftConsole (is it possible to attach it to the forum?)
Because of the issue I am considering to use the new Task notifications instead.
Thanks for any comment.