SemaphoregivefromISR()

Hi I am developing Interrupt based CAN for ARM cortex M4 and am facing issue inside the ISR ,I am using SemaphoreGivefromISR() from the ISR and it is not jumping to Semophoretake() function can anybody help me to solve this ?
my ISR code added below

{
BaseType_t reschedule;
reschedule=pdFALSE;
PRINTF(“ENTERED handler \r\n\n”);
if(xSemaphoreGiveFromISR(xSemaphore_producer,&reschedule)==pdPASS)
{
PRINTF(“Semaphore_producer passed\r\n”);
}
else
{
PRINTF("Failed to produce since semaphore is already available\r\n ");
}
portYIELD_FROM_ISR(reschedule);
}

Almost always using printf and friends in interrupt handlers causes any kind of problems.
It starts with excessive stack usage (stack of ISRs is special and often limited) and usually it‘s not even safe to use it in ISRs. Also try to keep ISRs as short as possible to minimize the impact to other ISRs of your application.
Remove the printf calls and very likely the problem is solved.

Also, if the semaphore has already been given, then the function will get a failure code (I believe) from the GiveFromISR.

Also, that task waiting on the semaphore will only run next if it was higher in priority than the currently running task. If it isn’t, it will need to wait its turn.

Hi Thank you for your valuable input ,my concern is execution is not exiting out of ISR ,even after successfully generating xSemaphoreGiveFromISR(); it is staying inside ISR for infinite times.

It ‘stays’ there probably due to fatal error or exception depending on how you handle these cases. Did you define configASSERT and the other debug options ?
I’d strongly propose to do so for development.
And is there a difference after removing the printf calls ?
Did you ensure that FreeRTOS with your tasks is properly started, the semaphore(s) are created etc. before enabling the interrupts in hardware ?
It’s a problem if an interrupt occurs before that / too early.
Best is to arm the interrupt by the task handling it. Then it’s ensured that everything needed is running and properly initialized.

If your ISR doesn’t end, then it is likely that your PRINTF isn’t really usable inside an ISR.