Sending to a message buffer AND notifying a task

nathanolacti wrote on Thursday, August 02, 2018:

Hi,

I am developing a software on a Cortex-M0.
Each task of the system usualy wait on their notification value.
When a hardware interrupt occures, I send a message to a message buffer through xMessageBufferSendFromISR and then wake the task using xTaskNotifyFromISR.
As I am calling two FromISR functions I am not really sure how to handle their pxHigherPriorityTaskWoken parameters.

Should I initialize it to pdFALSE, call xMessageBufferSendFromISR, portYIELD and then initialize it again, call xTaskNotifyFromISR and portYIELD ? or just initialize it once and call portYIELD each time ? or event call portYIELD only at the end ?

Regards,
Nathan O.

heinbali01 wrote on Thursday, August 02, 2018:

As I am calling two FromISR functions I am not really sure how to handle their
pxHigherPriorityTaskWoken parameters.

As simple as this:

    void myISR()
    {
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    
        xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, &xHigherPriorityTaskWoken );
        xTaskNotifyFromISR( xTask, ulValue, eSetBits, &xHigherPriorityTaskWoken );
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
    }

The two fromISR functions may set the variable xHigherPriorityTaskWoken. Once set, it won’t be cleared by a next function.

nathanolacti wrote on Friday, August 10, 2018:

Thank you very much for your answer. I will update my code accordingly.