Entering a critical section means that interrupts ( up to a certain priority ) are suppressed.
Now you call xSemaphoreTake() during a critical section: how can it block when interrupts are not allowed.
PS. Have you defined configASSERT() in a proper way ?
I would recommend to either use a semaphore, or a critical section, preferably the former.
A semaphore will stop other tasks from entering the protected section.
A critical section will stop other tasks and interrupts from executing.
Most API’s can not be called during a critical section.
The API can be called within a critical section, it just is not allowed for the code to actually block.
Note, xSemaphoreTask as an additional parameter, how long to block if the semaphore isn’t available, and returns a value, if it was successful.
You COULD have code that does a take with a 0 time to wait, and check if got the semaphore, and if it did, do some actions and then give the semaphore back.