I am using SYS/BIOS 6.34.2.18
I am currently using the Semaphore_pend to drive traffic over a USB bulk endpoint. I send one message and then wait for an interrupt to set a Semaphore_post before sending the next message. I set up the pend as follows:
if (Semaphore_pend(semUSBTransferComplete, 5000) == FALSE) //wait up to 5 seconds before timing out
My problem is the semaphore never times out and even though the semaphore has been set it doesn't trigger.
I have verified the bios clock is still active and the semaphore has been set by reading the clock tick and checking the semaphore count in an interrupt routine after I know the error has occurred. I used the following code to do this:
tickCount=Clock_getTicks();
count=Semaphore_getCount(semUSBTransferComplete);
The tickCount is changing and the semaphore count is 1 in the interrupt routine, so I know the Semaphore_post happened.
I send out 2 types of messages, the first is 32 bytes and the second can be very large. The problem only occurs on the 32 byte message on occasion. It seems when I start the USB transfer and then go to execute the semaphore wait something gets corrupted in the semaphore. I am guessing the code for the USB posting the semaphore is being executed during the code setting up the semaphore_pend. If the code for the post somehow gets set during the setup, maybe the blocking of the task does not get setup correctly.
I can make the problem go away by inserting a small delay between starting the USB and setting up the Pend. This would allow the Post to completely occur before the Pend gets started. The larger messages would take longer the finish so the small delay will still allow the Pend to be setup before the USB could complete, therefore the Post would happen after the task is in a pending state.
Inserting a small delay doesn't seem to be a great way to fix the problem since the USB could be paused equivelent to the delay.
Any help with this issue would be greatly appreciated.
Regards,
Bill