bolderflight / invensense-imu

Arduino and CMake library for communicating with the InvenSense MPU-6500, MPU-9250 and MPU-9255 nine-axis IMUs.
MIT License
498 stars 211 forks source link

Solution: Initialization errors on begin() // TEENSY 4.0 only #65

Closed ccdzapper closed 3 years ago

ccdzapper commented 4 years ago

While trying to use the library example Basic_SPI, with Teensy 4.0 and a generic MPU9250 board, I encountered initialization errors on IMU.begin(). The errors produced return codes of -5 & -8 . This was resolved by adding delays in two places in MPU9250.cpp: I do not know if this could be a permanent solution, but it worked for me without affecting sensor throughput as it is only in initialization as far as I can tell.

  1. delay(2); in the beginning of MPU9250::writeRegister(uint8_t subAddress, uint8_t data) before: _spi->beginTransaction(SPISettings(SPI_LS_CLOCK, MSBFIRST, SPI_MODE3));
  2. delay(1); in the beginning of int MPU9250::whoAmI()
    before: if (readRegisters(WHO_AM_I, 1, _buffer) < 0)

I am posting this in Issues in the hope that it will help someone else running across this or a similar issue. Thanks for a great library!

flybrianfly commented 3 years ago

Library updated to work with Teensy 4.x.