Hi all,
I am using ARM-CortexM7 and FreeRTOSv10.3.1.
I implemented mutex, but it is not working. Please see the code.
int main() {
initializeSystem();
LogDebugInt("----- Hello World -----\r\n", 5);
LogDebugInt("CPU Clock %dMHz\r\n", bsp_getCPUClock()/1000000);
LogDebugInt("Peripheral Clock %dMHz\r\n", bsp_getMasterClock()/1000000);
m_handle = xSemaphoreCreateMutex();
if(m_handle != NULL){
xTaskCreate(task1, "TASK-1", configMINIMAL_STACK_SIZE, NULL, 2, &t_handle1);
xTaskCreate(task2, "TASK-2", configMINIMAL_STACK_SIZE, NULL, 1, &t_handle2);
vTaskStartScheduler();
} else {
LogDebugInt("Failed to create Mutex.\r\n", 0);
}
}
void task1(void *param){
for(;;){
if(xSemaphoreTake(m_handle, ( TickType_t ) 10)){
LogDebugInt("Demo Task(T1): Printing by Task-1\r\n", 0);
xSemaphoreGive(m_handle);
}
vTaskDelay(pdMS_TO_TICKS(200));
}
}
void task2(void *param){
for(;;){
if(xSemaphoreTake(m_handle, ( TickType_t ) 10)){
LogDebugInt("Demo Task(T2): Message from Task-2\r\n", 0);
xSemaphoreGive(m_handle);
}
vTaskDelay(pdMS_TO_TICKS(200));
}
}
Please the output on console, after reboot.
ø----- Hello World -----
CPU Clock 300MHz
Peripheral Clock 150MHz
Demo Task(T1): Printing by Task-1
After that no msg on console, no msg from task-2. Can you help me to diagnose the problem?