Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze on initialization of DMP on MPU-6500 #43

Open
justacec opened this issue Sep 6, 2023 · 0 comments
Open

Freeze on initialization of DMP on MPU-6500 #43

justacec opened this issue Sep 6, 2023 · 0 comments

Comments

@justacec
Copy link

justacec commented Sep 6, 2023

I have been trying to get the DMP elements working on my MPU-6500 units and an RP Pico W using your library and the example code in the bbone_dmp file. Every time I try this I get the below referenced error. I am not sure if it is something I am doing wrong (I am using SPI, your example is based on I2C, is it required to use I2C to enable the DMP?), or is it not compatible with the 6500? I did look at the output of mpu9250::who_am_i(&self) and it returned 0x70 vice the stated 0x71 that this crates documentation highlights. The register map for the MPU-6500 states that the return should in-fact be 0x70. I chalk this up to the fact you have built this library around the MPU-9250 and not the MPU-6500 (however, the 6500 is officially supported in this crate). It does work and thank you for that.

If you could point me in the correct direction to fix this issue, that would be super great.

Error

ERROR panicked at src/main.rs:256:10:
called `Result::unwrap()` on an `Err` value: DmpFirmware
└─ <mod path> @ <file>:0

I believe this error is being thrown from this chunk of code from the mpu9250/src/lib.rs file:

    /// Load the provided firmware in the internal dmp memory
    fn load_firmware(&mut self, firmware: &[u8]) -> Result<(), Error<E>> {
        let mut buffer: [u8; 17] = [0; 17];
        let mut addr: u16 = 0;

        for chunk in firmware.chunks(16) {
            self.write_mem(addr, chunk)?;
            self.read_mem(addr, &mut buffer)?;
            if &buffer[1..chunk.len() + 1] != chunk {
                return Err(Error::DmpFirmware);
            }
            addr += chunk.len() as u16;
        }
        assert_eq!(addr as usize, firmware.len());

        const DMP_START_ADDR: [u8; 2] = [0x04, 0x00];
        self.dev.write_many(Register::DMP_START_ADDR, &DMP_START_ADDR)?;

        Ok(())
    }

Relevant Cargo.toml

mpu9250 = { version = "0.25", features = ["dmp"] }

Relevant Code from main.rs

use mpu9250::{Mpu9250, Imu, ImuMeasurements, Dmp, DMP_FIRMWARE};

.
.
.

    // Initialize the SPI and the Accel/Gyro
    let mut spi_config = spi::Config::default();
    let spi = spi::Spi::new_blocking(
        p.SPI0,
        p.PIN_2, // scl_sck
        p.PIN_3, // mosi
        p.PIN_4, // miso
        spi_config,
    );

    info!("Spi ok!");

    let ncs_pin = Output::new(p.PIN_5, Level::High);
    let mut mpu = Mpu9250::dmp_default(
        spi,
        ncs_pin,
        &mut Delay,
        &DMP_FIRMWARE
    )
        .unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant