5 years, 7 months ago.

How can I change pins for SPI (STM32F413H-DICO)

Hi everyone, I am using 32F413HDISCO and a simple SPI demo-program: "nucleo_spi_master". On this special board there seems to be an conflict with the WiFi module which uses the same line to SPI MISO (PB_4). So I tried to switch to other pins of the Arduino connector (CN6-CN9). But every time I when change a pin in the mbed::SPI function I got an "pinmap mismatch" error massage.

What's my mistake, how can I change the SPI pins?

my code is:

  1. include "mbed.h"
  2. include "SPI.h"

SPI device(SPI_MOSI, SPI_MISO, SPI_SCK); DigitalOut chipselect(SPI_CS); DigitalOut led(LED1);

int main() { int i = 0; device.format(8,0); device.frequency(100); while(1) { led = !led; chipselect=0; device.lock(); device.write(i++); device.unlock(); chipselect=1; wait_ms(200); } }

2 Answers

5 years, 7 months ago.

Hello Jens,

It seems that there are no additional SPI pins available at the Arduino headers.
Have you tried to deselect the WiFi module by pulling up the WIFI_SPI_CSN pin (PG_11)?

#include "mbed.h"
#include "SPI.h"

SPI device(SPI_MOSI, SPI_MISO, SPI_SCK);
DigitalOut chipselect(SPI_CS);
DigitalOut wifi_cs(PG_11);
DigitalOut led(LED1);

int main()
{
    int i = 0;
    device.format(8,0);
    device.frequency(100);
    wifi_cs = 1;        // deselect WiFi SPI slave
    chipselect = 1;
    while(1) {
        led = !led;
        chipselect=0;
        device.lock();
        device.write(i++);
        device.unlock();
        chipselect=1;
        wait_ms(200);
    }
}

Another option could be to keep the WiFi module in RESET mode:

#include "mbed.h"
#include "SPI.h"

SPI device(SPI_MOSI, SPI_MISO, SPI_SCK);
DigitalOut chipselect(SPI_CS);
DigitalOut wifi_rst(PH_1);
DigitalOut led(LED1);

int main()
{
    int i = 0;
    device.format(8,0);
    device.frequency(100);
    wifi_rst = 0;        // keep WiFi in reset mode
    chipselect = 1;
    while(1) {
        led = !led;
        chipselect=0;
        device.lock();
        device.write(i++);
        device.unlock();
        chipselect=1;
        wait_ms(200);
    }
}

Accepted Answer

Both suggestions solved my problems concerning MISO PB_4 - thank you very much!

posted by Jens Kampmann 24 Sep 2018
5 years, 7 months ago.

-