Hi all,
In past 2 weeks I'm banging my head around, connecting MPU-9250 on SPI protocol to Arduino Due. No luck so far. I read all documentation from Invesenses. IMO in theory this code should work perfectly but I got only 0xFF value.
The wiring is straight forward using this connectors:
Both are operational and fully working over I2C. The thing is they have only two adresses over I2C but I want faster response rate and chaining more then 10 sensors together.
If some one will have answer to my problem I'll be very thankful.
Sorry about begin snarky. I can't actually compile your code as I don't have the Due core. But I was hoping you'd show your wiring, either by diagram or photo. Maybe you made some silly mistake.
A quick look at the datasheet and I noticed this:
To prevent switching into I2C mode when using SPI, the I2C interface should be disabled by setting the I2C_IF_DIS configuration bit. Setting this bit should be performed immediately after waiting for the time specified by the "Start-Up Time for Register Read/Write" in Section 6.3.
But there is no Section 6.3 and no explanation of when exactly you're supposed to set this bit. How did you decide when to set it?
Address 0x6A, bit 0x10 is I2C_IF_DIS. In many examples (invensense examples to), the I2C_IF_DIS are set right after reseting the IMU. In many cases I2C_IF_DIS is not present in code and people still reports working SPI communication.
Well maybe that's not it. It's weird that the datasheet makes mention of it but then never goes any further. Also weird is that you ask if there might be an error in your wiring but never show it. If it's so trivial then why ask?
Looking at the datasheet again, the SPI timing diagram is for mode 1,1. But they never explicitly say what the mode is, so who knows.
CPOL=0 & CPHA=0 -> data are captured on the clock's rising edge (low→high transition) and data is propagated on a falling edge (high→low clock transition).
CPOL=1 & CPHA=1 -> data are captured on clock's rising edge and data is propagated on a falling edge.
Either way this dosn't do anything. Problem is lying somewhere else.
Also, my Due had problems if I set the CS pin as OUTPUT and HIGH, but I was using D10 as the CS. It did ok if I set it to HIGH only (not as an OUTPUT). I haven't tried D52.
I have successfully gotten the MPU-9250 working 100% via the SPI protocol. There is a little trick to it. Unfortunately for you, my code is wrote in the Propeller Spin language, but the same commands are required.
Once you push the initial setup values for the MPU-6050 (Accel & Gyro) and have valid data, the next step is to configure your first external sensor (AK8963). I set mine to operate on Slave0 but you can use any of Slave's 0-4.
When you read x bytes, it is reading registers from the start point, so to get above 16 (F) you start at register you wish to begin, then read x registers (bytes). This is how you have to get the ASA values from the Fuse ROM.
For both sensors, the Read Mask is %1000_0000 and the Write Mask is %0000_0000.
You must set the Slave# Address register to Read/Write before completing the action.
Hopefully you can use this as a guide to get yours working.
Hi Guys,
I am trying to communicate with mpu 9250 through spi. I am using due and I can read gyro and acc data just fine. but no luck with magnetometer. I cannot even read its fixed who am i reg. Since I am reading the acc & gyro data, I assume my connections should be okey (I am using 6 pin SPI in the middle of Due). I have been struggling with this issue for almost two weeks now. At this point, any help is really really appreciated. I have also attached the files I have been working on. basically I got a library for another chip and started to changing it.
Has anyone had any luck getting MPU-9250s' magnetometer to work with SPI? I've followed @IllExtractors steps but I get absolutely nothing. I can't even read the the WhoAmI register.