is the function”eTaskGetStateFromISR”exist?

Now,we are writing a project upon FreeRTOS. I wrote a function suspend one task using vTaskSuspend(task1),then when DMA interrupt occur,I resume the task in interrupt using function TaskResumeFromISR(task1 ); but i met some problem: sometimes DMA interrupt won’t occur(transmission broken) ,so the task won’t be resume. I plan to write one timeout check in TIM interrupt,like: void TIM interrupt(void)// 0.1 second { if(eTaskGetState(task1hadle) == eSuspended)
{ if( //check 100 times ) { vTaskDelete(task1) xTaskCreate(task1) } } } but now it’s halt in eTaskGetState : configASSERT( ( portNVIC
INTCTRLREG & portVECTACTIVE_MASK ) == 0 ); so like xTaskResumeFromISR and xTaskResume don’t we have a function called eTaskGetStateFromISR?

is the function”eTaskGetStateFromISR”exist?

oh no,when i saw the function “vTaskDelete(task1),xTaskCreate(task1)”,they all have the assert “configASSERT( ( portNVICINTCTRLREG & portVECTACTIVEMASK ) == 0 );” so ,is it impossible to execute according to my thought?

is the function”eTaskGetStateFromISR”exist?

well,now ,I think i have two solutions: 1.I set a global variable to receive the TIM interrupt times,and create a task that check the state of the task. like this: xTaskCreate(taskcheckfunctioin…) void TIM interrupt(void)// 0.1 second { givtimecount++; } void taskcheckfunctioin() { check according givtimecount;
if(eTaskGetState(task1hadle) == eSuspended) { if( //check 100 times ) { vTaskDelete(task1) xTaskCreate(task1) } } } 2.using Blocked state.I saw function like xQueueSendToBack or xSemaphoreTake. I can set number of timeout . when the interrupt occur ,release the semaphore.otherwise, timeout i will restart this task; like this: xSemaphore = xSemaphoreCreateBinary(); void DMA interrupt(void)// dma receive over { xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
} void task() { xSemaphoreTake( xSemaphore, portMAX
DELAY ); }

is the function”eTaskGetStateFromISR”exist?

Normally suspending/resuming a task like this is really the wrong thing to be doing. If the task wants to wait for a DMA interrupt then wait for a semaphore that is set by that interrupt. That way you can add a timeout on the wait and the task can handle its own cleanup. (You can also use the task notification system as a lightweight version of this). Also killing and restarting a task is a good way to mess up your program enviroment. Maybe you know that task doesn’t hold any resources in this case, but in general it can be very bad. On “Big” OSes, you can kill a PROCESS and restart it, as the OS knows what resources a process owns and can clean those up. Tasks are much more light weight.

is the function”eTaskGetStateFromISR”exist?

Just to re-iterate and emphasise Richard Damon’s point – using task suspend/resume as a synchronisation method in this way is dangerous and can lead to missed interrupts if there is a chance an interrupt arrived before the task has suspended. Suspending and resuming had no method of latching that an interrupt occured. I would also second the suggestion that the correct way to do this is with a semahore, because a semaphore does latch that an interrupt has occurred – better still use a direct to task notification as that is faster and has no RAM overhead. Regards.