Getting hard fault after xSemaphoreGiveFromISR at configASSERT( pxQueue->uxItemSize == 0 )

I have created one OS Task to monitor the ADC values. To scan the channels I’m using a hardware timer of 1ms. Every 1ms I’m initiating ADC scan. For synchronization I have used Binary Semaphore. From ADC ISR as soon as ‘n’ samples are acquired I’m releasing semaphore using xSemaphoreGiveFromISR. In OS Task I’m using xSemaphoreTake to acquire semaphore. It is working smoothly for some duration for e.g. 7-8seconds or even 10-15minutes. But later I’m getting an Hard Fault at
configASSERT( pxQueue->uxItemSize == 0 )

pxQueue->uxItemSize is holding an non-zero value and getting hardfault.

Thanks in advance.

In FreeRTOS semaphores and queues use the same data structures (originally done to keep the code size down). Unlike queues, semaphores do not pass data bytes, so the size of each queued item is expected to be zero. In your case it sounds like it is zero for as long as your application is working, but at some point it becomes non-zero, which triggers the assert. The most likely cause of that is a simple data corruption - something is writing over the queue data structure. If your debugger allows you to add data watchpoints then add a watch point on pxQueue->uxItemSize to break the debugger when something writes to it to see what went wrong.

As an aside, it would be more efficient for you to use a task notification in place of a binary semaphore.

You might also try searching the forum for pxQueue->uxItemSize == 0 and you’ll get a number if hits where in all cases a data corruption is the root cause problem as already pointed out by Richard. This could happen due to various reasons (read: bugs).
Did you define configASSERT , enabled stack overflow checking and maybe also configUSE_MALLOC_FAILED_HOOK (see Hook Functions doc ) for development/debugging ?
Very often this helps a lot finding the problem.