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.

MSP432P4111: Can a SWI's Trigger value be reset to its initial value, without triggering the SWI

Part Number: MSP432P4111

G'Day,

In SYSBIOS, SWI's have a trigger parameter with one of two uses. 

Calling Swi_inc() or Swi_or() post the SWI after having modifed the trigger value in a way that passes useful information (e.g. who posted the SWI, how many times the SWI was posted before it ran) into the SWI.

Calling Swi_dec() or Swi_andn() modify the preset trigger value and if its zero, the SWI is posted.  This lets you only post the SWI if certain conditions are true, and its this use I'm interested in.

In my application, I'd like to trigger my SWI if two conditions A and B both come true within a time window. 

I can use Swi_andn() to indicate when one of the conditions is met.  But how to I reset the trigger value at the start of each time window? 

The only way I know of resetting the trigger value is to post the SWI, which is not what I want! 

Is there another way to reset the trigger value?  

E.g. would it be safe do to something like the following?  Any limitations on when this could be done?

Swi_Handle swi0;

swi0->trigger = swi0->initTrigger;

Cheers

Julian

  • Hi,

    We will look into it and get back to you ASAP. Please bear with us.

    Thanks,

    PM

  • Thank you!

    I tried swi0->trigger = swi0->initTrigger, but compiler complains about an incomplete class so I gave up on that.

    I have worked around by posting the SWI at the start of each time period with a global variable set to indicate the SWI shouldn't do anything (other than clear the global variable).  My conditions for running the SWI can only come true later in the time period, so this works for me. 

    That said, if you can find a solution that avoids posting the SWI that would be much preferred. I'd like to avoid the context switch overhead and there is a risk with this approach (small in my case, but still real) that the SWI might not run until after one of the conditions is set in the current time period.  It would be much better to directly reset the SWIs trigger value in the timer HWI that signifies the start of the time period.

    Cheers

    Julian

  • Hi Julian,

    You can use Swi_setAttrs, which will set the trigger value to the supplied in value in the parameters. You probably want to use the Swi_getAttrs to populate the parameters structure and then tweak the trigger as desired. Please read the constraints of using Swi_setAttrs though. You cannot call it if the Swi has been preempted or is ready to run (thus the '*' in the Calling Context table for Swi_setAttrs in the API documentation).

    Todd

  • Thank you Todd, that's just what I was after.

    Thinking about it now, I guess another possible solution would be to implement the SWI trigger idiom in a general way - it's a useful idiom in other contexts.  Have a data structure where you can set and clear flags, and if all the flags are cleared, run a specified callback (which in this case would post the SWI). 

    Cheers

    Julian

**Attention** This is a public forum