I needed a mutex to control flow between a task and an ISR.
Code: Select all
xSemaphoreHandle SpiPackageComplete = 0;
vSemaphoreCreateBinary(SpiPackageComplete); // start of task
......
r = xSemaphoreTake(SpiPackageComplete, 5); // inside task's while(1)
Inside an ISR ...
xSemaphoreGiveFromISR(SpiPackageComplete, &HigherPriorityTaskWoken); // no task switch based on return
The Complete spi cycle takes just less an 700usec to complete. It takes 10 interrupt cycles to complete the spi package transmission.
The code as shown --- the return from the take should occur within the same tic count or the next and the interrupt counter should be 10 indicating a complete package. What occurs is that the task is NOT blocked by the TAKE and immediately returns (my interrupt counter is at 2 indicating 2 64 byte packages have been sent --- about 150usec.
I change the type of Semaphore binary counting of depth 1 --- and it works as expected.
Code: Select all
SpiPackageComplete = xSemaphoreCreateCounting(1, 0);
I've instrumented this thing multiple ways and every thing indicates the "Binary Semaphore" is NOT working properly -- it will NOT block until a GIVE occurs and return immediately.
Can you verify my findings?
Thanks