It is my understanding that my only option is a critical section using portENTER_CRITICAL and portEXIT_CRITICAL. When inside the critical section interrupts are disabled. This is what I want since I don't want the code in the loop() that modifies the shared variable to be interrupted by the ISR which also want to modify the share resources.
Two questions:
- It seems disabling ALL interrupts during the critical section is somewhat overkill? I just don't want the scheduler to be able to interrupt and the ISR for the external interrupt. All other interrupts should be fine since they don't touch the data? Is there a way to be more specific or is this an all or nothing thing?
- I read in another post on this forum that portENTER_CRITICAL_ISR is not required inside the ISR. Why is it safe to not call portENTER_CRITICAL_ISR? Could'nt the FreeRTOS scheduler ISR interrupt my ISR and start scheduling the loop task again somehow? Or will the scheduler never pre-empt an interrupt?