williamjsell wrote on Wednesday, August 12, 2015:
I made an error as I was taking a mutex from one task and giving it back in another task. This is not the correct way to signal tasks, so I replaced the mutex with a binary sempaphore:
for(;;)
{
//wait forever for a message. This updates the global variable "device"
xQueueReceive(calibrationQueue, &calDev, portMAX_DELAY);
//wait forever for the resource
xSemaphoreTake(calibrationSmphr, portMAX_DELAY);
//now update the public device
memcpy(&calibrateDevice, calDev, sizeof(_calibration_type_t));
//call the calibrate task
xEventGroupSetBits(xCalibrationGroup, calibrateDevice.calType);
}
The problem is the xSempahoreTake never returns on the first call to the function, so my system never gets started. Basically this task queues requests and waits for the semaphore to be available, before setting another event. When the calibration event is complete it gives back the semaphore. What am I doing wrong? I checked the semaphore has been properly allocated from CreateBinarySemaphore. When I substiture the mutex rather than binary semaphore, everything works.