MPU9250 on SPI issue - doesn't work !?!?

Discussion about libraries specific to the LibMaple core
Post Reply
mike28282
Posts: 12
Joined: Thu May 24, 2018 5:45 am

MPU9250 on SPI issue - doesn't work !?!?

Post by mike28282 » Fri Nov 09, 2018 4:39 pm

HI all,

I need to run two IMUs ( MPU 9250 x 2 or MPU 6050 x 2 ) on a Blue Pill (STM32F103C8T6 dev board)
I tried the options of using independent I2C ports, but i am having an issue as outlined here : http://stm32duinoforum.com/forum/viewtopic.php?f=2&t=4303

Since either I2C1 or I2C2 works, I thought I'd connect the 2nd IMU on SPI ports of the Blue Pill
I am using the following code that works fine on an Arduino UNO: https://github.com/brianc118/MPU9250
I used the Slave Select pin 10 on the UNO

I need to port it to the Blue pill , I'm trying the following... it DOESN'T work
MOSI on PB5
MISO on PB4
SCLK on PB3
SS on PC13 ( in SPI.h it says the default SS pin is PC13 or PA4, tried both ).

I ran the same code as the UNO with the above pin changes, it doesn't work... what am I doing wrong ???
portion of the code is

Code: Select all

#include 
#include "MPU9250.h"
#define SPI_CLOCK 8000000  // 8MHz clock works.
#define SS_PIN   PA4 // Slave select pin
MPU9250 mpu(SPI_CLOCK, SS_PIN);
void setup() {
	Serial1.begin(115200);
 	pinMode(SS_PIN, OUTPUT);
	SPI.begin();
	mpu.init(true);
the SPI class is generic and doesn't allow the user to choose SPI1 or SP2, is the default SPI1 port ?
there are Lib issues as outlined here http://stm32duinoforum.com/forum/viewtopic.php?t=82
What aspects of the my code and wiring need to be changed ?

Thanks in advance!

idahowalker
Posts: 26
Joined: Fri Nov 09, 2018 1:13 pm

Re: MPU9250 on SPI issue - doesn't work !?!?

Post by idahowalker » Sat Nov 10, 2018 11:53 pm

You could solder a jumper wire to AD0:+V on one of the MPU's to have it use the alternate address and have 2 MPU's on the same I2C bus. I recommend that for the other MPU606 you solder AD0 to ground. That way a floating state does not cause issues with 2 MPU's on the same bus.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: MPU9250 on SPI issue - doesn't work !?!?

Post by stevestrong » Sun Nov 11, 2018 7:48 am

SPI port 1 (which I think is the default for that lib) is on pins PA5-7.
Search the forum for how to use/switch between SPI ports.

Post Reply