Skip to main content
LAren
Visitor II
May 5, 2019
Question

Calling osDelay after osMailGet result in the micro stuck - using freeRTOS with CMSIS API

  • May 5, 2019
  • 0 replies
  • 449 views

I'm working on a project using a STM32F446 with a boilerplate created with STM32CubeMX (for peripherals initialization and middleware like the FreeRTOS with the CMSIS-V1 interface). I have two threads which communicate using mailboxes but I encountered a problem: one of the thread body is (I made it more understandable)

void StartDispatcherTask(void const * argument)
 
{
 
 mailCommand *commandData = NULL;
 
 mailCommandResponse *commandResponse = NULL;
 
 osEvent event;
 
 for(;;)
 
 { 
 
 event = osMailGet(commandMailHandle, osWaitForever);
 
 commandData = (mailCommand *)event.value.p;
 
 
 // Here is the problem
 
 osDelay(5000);
 
 }
 
}

It gets to the delay but never gets out. Is there a problem with using the mailbox and the delay in the same thread? I tried also bringing the delay before the for(;;) and it works.

Also, I can try to add more detail to the problem. The first thread send a mail of a certain type and then waits for a mail of another type; the thread in which I get the problem receive the mail go the first type and execute some code based on what it receive and then send the result as a mail of the second type; sometimes it is that it has to wait using osDelay and there it stop working but without going into any fault handler

This topic has been closed for replies.