Why must you use the FromISR API variants in an interrupt?
Short answer: Normal RTOS API functions may block (wait for space or data), and an ISR must never block because it is not a task and cannot be suspended. The ...FromISR variants never block, use interrupt-safe critical sections, and instead of switching context immediately, they report through a pxHigherPriorityTaskWoken flag that a higher-priority task became ready; the ISR then requests a context switch at its exit with portYIELD_FROM_ISR().
void UART_IRQHandler(void)
{
BaseType_t woken = pdFALSE;
uint8_t b = (uint8_t)UART->DR;
xQueueSendFromISR(rx_queue, &b, &woken); /* never blocks: fails if the queue is full */
portYIELD_FROM_ISR(woken); /* pend PendSV if a higher-priority task was woken */
}
Why the deferred switch: the ISR may be nested inside other ISRs, and it may wake several tasks; requesting a switch once at the end (via PendSV, which runs after all ISRs) is safe and efficient. If you forget portYIELD_FROM_ISR, the woken task only runs at the next tick or scheduling point, adding up to one tick of latency.
Interrupt priority rule (Cortex-M): only interrupts with a priority numerically greater than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY (i.e. less urgent) may call FreeRTOS APIs. The kernel masks interrupts up to that level in its critical sections; a more urgent ISR could interrupt the kernel mid-update, so it must not call the API. Getting this wrong causes rare, random corruption; enable configASSERT(), which checks it in vPortValidateInterruptPriority().
Other systems: Zephyr uses the same functions from ISRs but requires K_NO_WAIT timeouts (calls with waiting fail in ISRs); CMSIS-RTOS2 functions check __get_IPSR() and behave accordingly; ThreadX allows certain services from ISRs with TX_NO_WAIT.