xMessageBufferReceive() should never return because nothing is ever sent to onlyForTestBuf(), yet BeepMini() seems to execute - indicating that xMessageBufferReceive() did infact return.
MessageBufferHandle_t onlyForTestBuf; //this is global var
//at task
onlyForTestBuf = xMessageBufferCreate(24);
for(;;)
{
xMessageBufferReceive(onlyForTestBuf, ( void * )myMessage, sizeof(myMessage), portMAX_DELAY ); //portMAX_DELAY
BeepMini();
}
void TIM3_IRQHandler(void)
{
xTaskNotifyFromISR(MotorsActionsHandle, PWMIR_FAULT, eSetValueWithOverwrite, NULL);
TIM3->SR = 0;
while(TIM3->SR &= TIM_SR_CC1IF);
//HAL_TIM_IRQHandler(&htim3);
}
I don’t use onlyForTestBuf at any place! No more can add into onlyForTestBuf! But I hear Beep because of my function BeepMini(). But if I delete xTaskNotifyFromISR from my interrupt no more beep. This is because stream_buffer.c:
size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, ...
/ *Wait for data to be available.* /
....
( void ) xTaskNotifyWait( ( uint32_t ) 0, UINT32_MAX, NULL, xTicksToWait );
In my interrupt I send via xTaskNotifyFromISR too! Is it a bug or feature? For example task is wating MessageBuffer, but in some moment there is a notify. So task stops wating MessageBuffer and process notify. But ulBitsToClearOnExit of xTaskNotifyWait not using at all! This is a bug I think. Old bit will set after every xTaskNotify.
while(!xMessageBufferReceive(xMotorActionMessageBuffer, ( void * )myMessage, sizeof(myMessage), portMAX_DELAY)){
ulNotifiedValue = 0;
if(xTaskNotifyWait(0x00, ULONG_MAX, &ulNotifiedValue, 100)){
//never be here
}
if(ulNotifiedValue & vMAPleaseReinit){
BeepMini(); //vMAPleaseReinit bit never cleared
}
};
This is because tasks.c:
if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED )
{
/* A notification was not received. */
xReturn = pdFALSE; //this is problem, taskNOTIFICATION_RECEIVED was received by xMessageBufferReceive
}
else
{
/* A notification was already pending or a notification was
received while the task was waiting. */
pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnExit;
xReturn = pdTRUE;
}
FreeRTOS 10