Reading IMU Outputs Faster

I have a circuit which has:

  • STM32F446RET6 MCU
  • 2 IMUs
  • 1 Barometer Sensor
  • 1 Micro SD Card Module
  • 1 External Flash Chip
  • 1 GPS Module
  • 1 LoRa Module

And when I try to use all of them in my code I can only achieve 6 to 8 while cycles in a second which means 6 to 8 sensor readings per second which is really slow considering I need to integrate gyro and accelerometer datas.

How can I achieve more sensor readings in a while loop? I heard that interrupt usage can help but I'm not sure. Can interrupt help in my situation? (Both IMUs have interrupt outputs.)

Answers 1

  • Don't do them in a while loop is how you read them faster. You microcontroller has many features that allow communications to be handled in the hardware peripherals instead of by your software which has only one thread of execution (assuming no RTOS is present). I assume your sensors are some mix of SPI, I2C and UART. Do some research on how to setup these hardware peripherals to use interrupts and DMA, there are plenty of good examples out there.


Related Questions