7 years, 9 months ago.

SPI4 problem

Hello.

I have to work with all five SPIs simultaneously. I've read the datasheet on STM32F411RE, tested SPI1, SPI2, SPI3, SPI5, all working except SPI4. I tried to use PB13 (SCK), PA11 (MISO), PA1 (MOSI) as described in datasheet, but I cannot get any data from SPI.

Any suggestions?

Best regards, Slobodan

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F411RET6 microcontroller.

1 Answer

7 years, 9 months ago.

Hello Slobodan

Not all pin muxing capabilities are provided as of now. In your case the limitation comes from the lines below: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/PeripheralPins.c#L204

There are ongoing discussion to be able to use any muxing capability. The proposal was done here: https://github.com/ARMmbed/mbed-os/pull/3181

If you apply the idea to your case, you'd need to modify the line https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411RE/PeripheralPins.c#L204

{PB_13, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI4)},

with

{PB_13_ALT6, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI4)},

and then you would create your SPI instance by referring to PB_13_ALT6 for SCK. I think the other pins would be fine already.

Can you give it a try ?

best regards Laurent

Accepted Answer

Thanks Master Yoda! Works great!

I just deleted mbed bin file from project, downloaded mbed-dev library from:

https://developer.mbed.org/handbook/mbed-library-internals

and changed comments on 203 and 204 line.

And it works like a charm. :D

Can I just ask you one more question?

I plan to use 5 SPIs at the same time, to acquire signals from 4 AD convertors and to store data on SD card. And i plan to connect it like in the image: https://drive.google.com/open?id=0B5TVXotY4T65d1gyUWgzOWRKV2s

My question is, will I have some problems running all SPIs simultaneously?

Regards, Slobodan

posted by Slobodan Draskovic 31 Jan 2017

Good news that your solution works fine. I don't think you'd have issues with using the various SPIs, Just note that PA_5 is also used for the LED. Of course you may not reach very high sampling rate on all SPI simultaneously. Let us know in case you face any issue.

posted by Laurent Meunier 31 Jan 2017