The MPU9250 is quite old, I am surprised you are using it for a new project. The problem with it is, the MPL software is on your host processor, which means any missing gyro data can mess the whole algo. Also, it is VERY sensitive to mag calibration, if it is not calibrated correctly, your reading will be off. Have you tried running the MPL without mag?
I've been using MPU9250 just for a while - it is very sensitive to vibrations. Now I am working with MPU6000. I can read accel & gyro data at 20 MHz over SPI. Magnetometer is not needed that much. Yaw drifts a bit without it but it is quite ok.
I have some plans with ESP32 pico and ICM20689 but as I am still struggling with software I don't want to make more investments now. That is why I am using old sensors (many new flight controllers still use MPU6000).
There is my current problem with FreeRTOS / ESP-IDF:
I am measuring how long it takes to run this function
https://pastebin.com/BsnfC0g8. For my needs it takes way too long to run it.
When I run this function inside a critical section it takes up to 200 us to run it. It is very strange without a critical section.
At the beggining it takes up to 500 us to run it but after a while it goes really crazy - up to 5 ms.
I tried to look deeper into it. Right after the function completes INTENABLE register contains 0x13000044. That means that interrupts 2, 6, 24, 25 and 28 are enabled on the current core. Critical sections disable only interrupts level 3 and below. So only interrupts 2 and 6 may cause that great delays. There is also a small chance that math functions use interrupts but I don't think this is the case.
Interrupt 6 is FreeRTOS tick interrupt. Interrupt 2 is bound to esp_crosscore_isr (I know that from _xt_interrupt_table
https://github.com/espressif/esp-idf/bl ... .S#L78-L89).
I will keep trying getting more info about it. But in the meanwhile is it normal behavior that it takes so long?
EDIT:
I believe I can confirm that those delays are cause by FreeRTOS tick handler. I replaced critical section by XTOS_SET_INTLEVEL(1). That disables level 1 interrupts only. Using this there are no delays. But after changing FreeRTOS tick handler to level 3 interrupt in menuconfig the problem occurs again.