Im using an ESP32 with the Arduino framework to control a robot that needs a control rate of at least 2000hz but ideal would be 4000hz. My idea was to get one task to only read sensor data from an MPU9250 at 4khz and another task to send data to a computer.
Problem is if i dont use a delay function and just check if enough time has past to read the sensor, the other task to send data is blocked and wont run or very slowly. Is far as ive seen and understand, the delay function only goes down to 1ms which gives me a max of 1khz and delayMicroseconds doesnt free the cpu.
How can i get around this problem without putting everything in one task?