taskENTER_CRITICAL in ISR?

Hi Ric,

you need to understand that w/ ISRs vs. tasks, mutual exclusion is asymmetric. If the concurrent read to the variable decremented by your ISR resides in a task or an ISR with an interrupt priority lower than the ISR that decrements it, you’re always safe (regardless of whether the increment/decrement is atomic or not) because the ISR will never be interrupted by the concurrent code and so execute the decrement “pseudo atomic” (meaning not necessarily in a single instruction but without danger of the value becoming incoherent).

A task (or lower-PRI ISR) that would need to modify (not just read, as richard_damon pointed out) the variable concurrently would have to employ an interrupt suspension mechanism to prevent data corruption, but note that the FreeRTOS critical section might not suffice here (if the ISR resides above configMAX_SYSCALL_INTERRUPT_PRIORITY, it will not be disabled by the critical section).