2 years, 5 months ago.

SPI_CS has a wrong pin number on the picture

Hi, the definition of the SPI Pin CS is as follow

const PinMap PinMap_SPI_SSEL[] = {
    {PA_4,  SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF0_SPI1)},
    {PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF0_SPI1)},
    {PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF0_SPI2)},
    {NC,    NC,    0}

this means the PB_6 is wrong if you choose that and the SPI will not work. Please fix that in the picture

The same mistake is there in the code .. the definition of the pins as bellow

    // Standardized button names
    BUTTON1 = USER_BUTTON,
    SERIAL_TX   = PA_2,
    SERIAL_RX   = PA_3,
    USBTX       = PA_2,
    USBRX       = PA_3,
    I2C_SCL     = PB_8,
    I2C_SDA     = PB_9,
    SPI_MOSI    = PA_7,
    SPI_MISO    = PA_6,
    SPI_SCK     = PA_5,
    SPI_CS      = PB_6,
    PWM_OUT     = PC_7,

/Mariwan

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F030R8T6 microcontroller.
Comment on this question

1 Answer

2 years, 5 months ago.

Dear Mariwan

Thank you for your interest. Could you provide me with the link of the picture you would like to be fixed ? I cannot see SPI in PB_6 of NUCLEO_F030R8.

You can use PB_6 as a SPI chip select. This is a software chip select, that you declare as a DigitalOut. You have every details here : https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/interfaces/digital/SPI/

In your case, you can use

#include "mbed.h"
 
SPI spi(D11, D12, D13); // mosi, miso, sclk
DigitalOut cs(D10);
 

or

#include "mbed.h"
 
SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK); // mosi, miso, sclk
DigitalOut cs(SPI_CS);
 

I hope this helps

Kind regards

Armelle

You used D10. If you use SPISlave .. you will get an error for the CS. D10 is the same as PB_6 and it is as I am showing in the firs pieces of code, not defined as CS for the SPI. look at this picture, it is printed on the module (i.e the CS near to pin PB_6). https://media.digikey.com/Photos/STMicro%20Photos/MFG_NUCLEO.jpg

The error I get is as follow:

pinmap not found for peripheral

posted by Mariwan J. 12 Jun 2017

Hi, I see what is going on.

SPI_CS=PB_6

works for any SPI master example that uses Arduino naming convention. This is commonly used and will therefore not be removed.

You want to initialize a SPI slave. You should use a hardware SPIx_NSS pin to make it work. You can trust SPIx_NSS from the pinout pictures available on the platform web page : https://developer.mbed.org/platforms/ST-Nucleo-F030R8/

In particular: SPI1 NSS is available on PA_4 / A2 pin of the nucleo platform.

https://developer.mbed.org/media/uploads/bcostm/nucleo64_revc_f030r8_mbed_pinout_v2_arduino.png

Kind regards

posted by Armelle DubocST 12 Jun 2017