# SPI configuration

**URL:** <https://discuss.px4.io/t/spi-configuration/4362>\
**Category:** Uncategorized\
**Created:** [September 7, 2017, 2:09pm UTC](https://discuss.px4.io/t/spi-configuration/4362 "2017-09-07T14:09:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoEon\_Lee](https://discuss.px4.io/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@DoEon\_Lee](https://discuss.px4.io/u/DoEon_Lee)\
**Post date:** [September 7, 2017, 2:09pm UTC](https://discuss.px4.io/t/spi-configuration/4362/1 "2017-09-07T14:09:19Z")

</div>

Hi ! 🙂

I’m trying to change the SPI number for MPU9250. (SPI1 → SPI2)

I think the SPI initialization has no problem, but the connection with MPU9250 is not established.

So, I can find the probe error (**‘MPU9250\_SPI::probe()’** function in **‘mpu9250\_spi.cpp’** file). The ‘ **whoami** ’ value is set to ‘0’ and CS pin is actived.

![](https://discuss.px4.io/uploads/default/original/2X/e/ecc260f791cafa7228be33de3c674f53b5a7aa28.png)

I tried to use both the other CS, DRDY pins and original pins.

In addition, what does the ‘bus’ mean? and how is it set up?

---

<div class="post-metadata">

**Author:** ![ksschwabe](https://discuss.px4.io/letter_avatar_proxy/v4/letter/k/b782af/32.png) [@ksschwabe](https://discuss.px4.io/u/ksschwabe)\
**Post date:** [September 7, 2017, 4:12pm UTC](https://discuss.px4.io/t/spi-configuration/4362/2 "2017-09-07T16:12:09Z")

</div>

If you look at the MPU9250 driver, you will see that it is trying to use the `PX4_SPI_BUS_SENSORS` bus as the SPI bus. This bus is set in the board\_config.h file for the board (remember there is a board\_config.h for each board). In board\_config.h you will probably see something like this:

```auto
#define PX4_SPI_BUS_SENSORS 1
#define PX4_SPI_BUS_RAMTRON 2
#define PX4_SPI_BUS_BARO PX4_SPI_BUS_RAMTRON

```

If you change the PX4\_SPI\_BUS\_SENSORS bus to be 2, then in px4fmu\_spi.c then you will also have to change the SPI select function from stm32\_spi1select() to be stm32\_spi2select().

But be careful. If you change the MPU9250 to be on another SPI bus, are you changing all of your sensors for your new board to be on this new bus. The one assumption that is made in most of the Px4 sensor drivers is that the onboard sensors are all on the same `PX4_SPI_BUS_SENSORS` bus.

---

<div class="post-metadata">

**Author:** ![DoEon\_Lee](https://discuss.px4.io/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@DoEon\_Lee](https://discuss.px4.io/u/DoEon_Lee)\
**Post date:** [September 8, 2017, 1:29am UTC](https://discuss.px4.io/t/spi-configuration/4362/3 "2017-09-08T01:29:49Z")

</div>

I changed the `PX4_SPI_BUS_SENSORS` and solved this problem !!

Thank you for your help ^^ 🙂

---

<div class="post-metadata">

**Author:** ![ksschwabe](https://discuss.px4.io/letter_avatar_proxy/v4/letter/k/b782af/32.png) [@ksschwabe](https://discuss.px4.io/u/ksschwabe)\
**Post date:** [September 8, 2017, 6:13am UTC](https://discuss.px4.io/t/spi-configuration/4362/4 "2017-09-08T06:13:19Z")

</div>

You will just have to be careful about adding other sensors to the bus and make sure that the stm32\_spi2select() function is adapted appropriately for the additional sensors that you add.
