OSSemPend not allowing other code to run

Discussion to talk about software related topics only.
Post Reply
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

OSSemPend not allowing other code to run

Post 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
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: OSSemPend not allowing other code to run

Post by pbreed »

Are you sure the timer or whatever is posting to the Semaphore is actually posting?
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

Re: OSSemPend not allowing other code to run

Post 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.
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: OSSemPend not allowing other code to run

Post 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)
shockwave77598
Posts: 22
Joined: Sat May 27, 2017 10:38 am

Re: OSSemPend not allowing other code to run

Post by shockwave77598 »

Problem solved.

Behold, the magic of:

OSSimpleTaskCreate( Time_Handler, MAIN_PRIO - 1);

Thanks everyone.
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: OSSemPend not allowing other code to run

Post by pbreed »

Glad you got it working.
Post Reply