Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 2 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:
- include "mbed.h"
- 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
6 years, 2 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); } }