Hi @richard-damon,
You are telling if I am taking the mutex before starting the scheduler with the zero wait time it won’t cause any issue right? Can I use like I mentioned a code below?
#include "FreeRTOS.h"
#include "task.h"
#include "stm32f4xx_hal.h"
#include "semphr.h"
void MX_GPIO_Init(void);
void Task1_BlinkLED1(void *pvParameters);
void Task2_BlinkLED2(void *pvParameters);
SemaphoreHandle_t mutex_handle;
int main(void)
{
HAL_Init();
MX_GPIO_Init();
mutex_handle = xSemaphoreCreateMutex();
// Create tasks
xTaskCreate(Task1_BlinkLED1, "LED1", 128, NULL, 1, NULL);
xTaskCreate(Task2_BlinkLED2, "LED2", 128, NULL, 1, NULL);
// Start the scheduler
send_char('A',0);
vTaskStartScheduler();
while (1) {}
}
void Task1(void *pvParameters)
{
while (1)
{
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void Task2(void *pvParameters)
{
while (1)
{
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void send_char(uint8_t data,uint8_t wait_time)
{
if(NULL != mutex_handle)
{
xSemaphoreTake(mutex_handle,pdMS_TO_TICKS(wait_time));
}
else
{
return;
}
send_uart(data,1);
xSemaphoreGive(mutex_handle);
}