Portenta H7 SPI4

Hi Everyone!

I am trying to setup an SPI4 on Portenta H7, so that I can have 2 peripheral devices on their own separate SPI bus. But, I can't seem to get it working yet and not sure if I'm doing the wrong SPI setup or if I'm referencing the pins incorrectly.

I have a custom breakout board and am wanting to use pins: PE2 (SCK), PE5 (MISO), PE6 (MOSI) and PE3 (CS) of the H7.

I'm doing this to try to get the SPI going:

#define PIN_SPI4_SCK   PE_2
#define PIN_SPI4_MISO  PE_5
#define PIN_SPI4_MOSI  PE_6
#define PIN_SPI4_CS PE_3

MbedSPI spi4(PIN_SPI4_MISO, PIN_SPI4_MOSI, PIN_SPI4_SCK);

void setup() {

  spi4.begin();  // Start SPI4 communication

  pinMode(IMU_CS_PIN, OUTPUT);

}

When I try this, the SPI device I'm trying to talk to says "device not detected". I'm using a standard hookup and have debugged that already to be connected fine and in accordance with a working reference design.

Can anyone let me know if I'm doing this right or if for example:

  • Wrong naming of the pins I'm trying to use?
  • Wrong way to setup the SPI4?
  • Any setup steps I'm doing wrong or missing?

I have set it up this way based on some direction given in this post: Portenta H7: Want to use STM32H747XI's SPI3 - #16 by tjaekel

Thanks in advance for any advice anyone may have who has experience with using additional SPI's on the Portenta H7!!!

Hi Disco,
PE2, PE5, PE6 are used for other purposes: PE2 = PDM CK, PE5 = SAI1A_SCK, PE6 = SDAI1A_SD.
PE5 and PE6 go to a level shifter U7 (for Video).
Potentially, you can still use as SPI4 pins (just to be aware that SPI4 would potentially toggle some Video signals).
The pins you want to use are correct (they have an ALT mode for SPI4).
I assume, Mbed does not support these pins as SPI4.
There are threads in Internet where people struggle to use SPI4 on other boards (so, I assume it is an Mbed SW issue), e.g.:
https://os.mbed.com/questions/76832/SPI4-problem/

Not so familiar with MBED (I am not using it), but what I see:

  • Why MbedSPI spi4(...) ? Should it be SPI spi4(...)
  • It looks to me, the order of the pins is wrong: SPI(MOSI, MISO, SCKL), you have (MISO, MOSI, SCLK), MISO and MOSI in reverse order.

"Who" is complaining about "device not detected"? I assume your slave chip, not Arduino Mbed.
Do you have a scope in order to verify if the signals come out properly?

You can also test by: use a wire and connect MISO with MOSI: all what you send - you should also receive. (but it does not make sure if SCLK and CS comes out, just MOSI and MISO).

What is IMU_CS_PIN? Is it the same as PIN_SPI4_CS (used as GPIO4 on Portenta H7 board)?
Do you drive CS (it is used here in SW mode)?