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.

Posting to a Mailbox from a SWI

Other Parts Discussed in Thread: CC1101, SYSBIOS

I am creating a radio receiver using a Tiva-C device interfaced to a CC1101 radio. When the CC1101 has received a packet, it triggers a hardware interrupt that posts a Swi. The Swi then goes and reads the packet from the CC1101's FIFO.

After I read the packet, I am trying to post it to a mailbox from the Swi so a lower-level task can process it later. However, I am getting an error: "ti.sysbios.knl.Semaphore: line 289: assertion failure: A_badContext: bad calling context. Must be called from a Task."

So my question is, if I can't post to a mailbox from a Swi, what is the best way to go about achieving this same functionality in a time-sensitive manner? Should I use a high priority task in the place of the Swi? Or is there a better approach that I'm overlooking?

  • Tyler Horton said:
    So my question is, if I can't post to a mailbox from a Swi, what is the best way to go about achieving this same functionality in a time-sensitive manner?

    You can post a Mailbox from a Swi, but only if your timeout parameter is BIOS_NO_WAIT (0 timeout).  When passing BIOS_NO_WAIT, Mailbox_post() can return FALSE to indicate that there was no available buffer in which to copy your Mailbox data.  If you carefully manage your Mailbox_post/Mailbox_pend pairs then you can "know" that there will be a buffer available, but it's always wise to be prepared to handle a FALSE return.

    Tyler Horton said:
    Should I use a high priority task in the place of the Swi?

    You could use a high priority Task, but that will obviously incur higher overhead/latency.

    To do so, your Swi can post a Semaphore or Event that is pended on by your high priority Task, and the high priority Task can then call Mailbox_post() (with whatever timeout is appropriate, possibly even BIOS_WAIT_FOREVER), possibly blocking until there is an available buffer (which would wait until the Mailbox consumer called Mailbox_pend()).

    Regards,

    - Rob