10 years, 2 months ago.

usage of spi3 on F401RE

Hi,

i just want to use the spi3 interface on the morpho headers of the board, but it doesnt work well.

I can't initiate the interface using the spi class.

what do i have to do it work.

bye and thanks.

1 Answer

10 years, 2 months ago.

A lot of the alternate functions for pins have not yet been implemented in the current mbed library for the nucleo's. Work is ongoing, but it may take a while. You can can try it yourself by deleting the mbed lib in your project, importing the mbed source code instead, and modify that for your target platform F401. In this case you will have to adapt mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/spi_api.c

There is an mbed lib source version available for the F401 that has been adapted by Peter. You can find it here

Look for:

static const PinMap PinMap_SPI_MOSI[] = {
    {PA_7,  SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
    {PB_5,  SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
    {PC_3,  SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
    {PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
    {PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
    {PB_5 , SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, 
    {NC,    NC,    0}
};

Adapt these tables when you don't find the pins that you need. Check the F401 manual for details.