We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
The problem is similar to http://www.keil.com/forum/9257/ . I don't know whether it was solved.
when I call osSemaphoreWait(), the returned value is 0xFFFFFFFF (-1) , which is happened when I use hardware timer independently. The code is showing below,
int32_t sem; osSemaphoreId rl_sem[1]; osSemaphoreDef(sem_0); //user thread 1 Thread() { rl_sem[0]=osSemaphoreCreate(osSemaphore(sem_0),1); while(1) { ... sem = osSemaphoreWait(rl_sem[0],0); printf("sem=%d",sem); //sem normally should be 1, but here it is 0xFFFFFFFF, ie, -1 } } //CAN ISR CAN_IRQHandler() { ... osSemaphoreRelease(rl_sem[0]); } //timer ISR Timer_Callback() { // nothing to do with semaphore }
your advice is much appreciated!
sorry, I find I use "printf" in Timer IRQ, that resulted in the second problem. But semaphore problem is still not solved.
now, I find the problem, I look into the source code, and osSemaphoreWait is not allowed in ISR, so it returns -1. Thank you!