I created two tasks: vCore_Loop (uxPriority = 4, launched every 5ms) and vScreen_Loop (uxPriority = 3, launched every 1ms).
vScreen_Loop communicates with a graphical screen via I2C. This low-priority task is often swapped by vCore_Loop task. My problem happens when vScreen_Loop is swapped during an I2C communication: my I2C driver creates an error because the communication is badly interrupted.
To solve this trouble, I added taskENTER_CRITICAL(); and taskEXIT_CRITICAL(); between the beggining and the end of the I2C communication function, to be sure that this region will not be swapped by the RTOS scheduler.
To my surprise it did not affect the task swapping, vScreen_Loop is still swapped by vCore_Loop during the I2C communication. Do you have any ideas of why?
note: if the I2C communication function is called by the high-priority task vCore_Loop I have no troubles.
Thanks a lot for your help!