Page 1 of 1

OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 11:59 am
by shockwave77598
I have a project I'm building for MOD5270.

I have a main loop. At the beginning of it, during the initializing. the Semaphores are initialized and the timers started.

I then call the subroutines that will pend and wait for a semaphore before continuing on. Now, calling this subroutine, the code should return to main() once the Pend is hit. Correct? But the code never leaves this routine -- call Time_Handler and you're stuck in it. Shouldn't the code that's pending release to the main loop again?

void Time_Handler(char * inbuffer, char * outbuffer, UINT16 * resbuffer)
{
ptrIn = inbuffer;
ptrOut = outbuffer;
ptrRes = resbuffer;
spifunction = 1;
while(1)
{
OSSemPend( &TIME_SEM, 0 ); // wait for semaphore but doesn't let anything else run

Re: OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 12:06 pm
by pbreed
Are you sure the timer or whatever is posting to the Semaphore is actually posting?

Re: OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 12:35 pm
by shockwave77598
Yes the 10hz timer is going off. It calls a SPI function and the spi traffic appears on my OScope. And as I ahve rewritten it, the SPI semaphore goes off as well. But this pending on the QSPI SEM is merely blocking till the Spi is finished. While somewhat functional, it's not the Start-pend approach I expected. How can I start a subroutine and pend within it and still run other code while the pend is waiting? I have to be doing something fundamentally wrong.

What I want to do is start two subroutines. One pends on a TIMER_SEM and the other pends on a QSPI_SEM. Both subs are endless loops. And I'm unable to execute anything else when I enter the first subroutine and the first pend. It never exits. I need to have subroutines that execute on the Semaphores. I think I'm doing it wrong.

Re: OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 2:14 pm
by pbreed
Did you create new tasks?
If so what priorities?

When you run the utility taskscan what do you see?
(You may have to run that as administrator)

Re: OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 4:03 pm
by shockwave77598
Problem solved.

Behold, the magic of:

OSSimpleTaskCreate( Time_Handler, MAIN_PRIO - 1);

Thanks everyone.

Re: OSSemPend not allowing other code to run

Posted: Mon Feb 01, 2021 6:01 pm
by pbreed
Glad you got it working.