This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320C6412: SWI_inc executed with mbox value of zero?

Part Number: TMS320C6412

Hi TI gurus

Following on from a previous posting, I was able to use SWI_inc() rather than SWI_post() in my legacy C64x DSP application.

SInce I am unable to use CCS or other tools, I have added debug code, I have seen definate cases of multiple SWIs being posted to the SWI queue prior to the first one being executed.

In these cases, the C6000 DSP BIOS users guide (Software Interrupt - Thread Scheduling) suggests using the following piece of code.


{ . . .
repetitions = SWI_getmbox();
while (repetitions --){
‘run SWI routine‘
. . .

I am monitoring the SWI_getbox value and counted the number of times that repetitions=0, 1 or 2

While I do see a problem where very occasionally (during busy periods) repetiions returns a value of 2, 95% of the time this value is 1. However, what really confused me, and actually caused the above piece of code to fail, was the other 5% of the time that the value of repetitions was equal to ZERO. This means that the while loop above will not execute at all.

I can't explain why that would happen, since surely to have the SWI executed, the mbox value must have been at least zero.

Am I missing something?



  • Hi,

    An afterthought. Could this be caused by an inadvertant SWI_post() and resultant SWI_getmbox() check?

    I will check for this condition, but if this is not occurring what other possibilities are there?

    Thank you!


  • Hi Jim,

    From the TMS320C6000 DSP/BIOS 5.31 API Reference, I found that:

    When SWI_getmbox is called from the context of a SWI, the value returned is zero if the SWI was posted by a call to SWI_andn, SWI_andnHook, or SWI_dec. Therefore, SWI_getmbox provides relevant information only if the SWI was posted by a call to SWI_inc, SWI_or, SWI_orHook, or SWI_post.

    Could this be occurring in your application?


  • Hi Derrick, It seems that by mistake, 5% of the calls were still SWI_post() calls (the rest were SWI_inc() calls) . So, .... within the context of a SWI_post() , SWI_getmbox was reading back zero in those cases . In the SWI_inc() cases SWI_getmbox returns one [ or sometimes two in the problem scenarios I am trying to address]. I guess this can also depend on the initialised value of the SWI that is used in the SWI_post call (in this case it's likely zero). Does that make sense?



  • Jim,

    Based on my understanding you're only using SWI_inc() calls now.

    It is possible that your application is calling SWI_inc() twice before entry into your SWI function? A value of two returned from SWI_getmbox() indicates exactly that.

    Are you calling SWI_inc() from a HWI context?


  • Did this get resolved?

    [10/2 update: Marking as TI Thinks Resolved due to no response from original poster]