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.
9 years, 4 months ago.
The SPI4 cannot be configured for STM32F411 Nucleo
Hi, I am new to the mbed online IDE and recently working on the SPI for Nucleo411 board. There are in total five SPI in Nucleo and we are required to use SPI4 instead of other four. However, when configure the MISO, MOSI, SLK pins for SPI4, it seems like doesn't work at all, because there is no message shown on my logic analyzer. Based on the manual, I found the following pins for configuring SPI4: MOSI: PA_1, MISO: PA_11, SCK: PB_3 and I choose PC_4 for chip select pin. The following is my code:
- include "mbed.h"
- include "SPI.h"
SPI spi(PA_1, PA_11, PB_13); DigitalOut ss(PC_4);
int main() { ss = 1; spi.format(8,1); spi.frequency(1000000);
while(1) { ss = 0; spi.write(0x01); spi.write(0x02); wait_us(5); ss = 1; wait_us(20); }
}
I had tried other four SPIs by only changing the configuration part, and they all worked. So anyone know the reason for this SPI4 problem?
edit:Ignore this (it's defined in PeripheralNames.h)
Looks like the SPI4 is not enabled in the device.h file Try
- define SPI4_BASE 1
just after your includes
(may have to use mbed-src as library instead of mbed, i.e. import mbed-src and delete mbed (compiled) from your project
posted by Martin Simpson 18 Aug 2015Looks like there's no SCLK pin for SPI4:
posted by David Lowe 18 Aug 2015<<code title=PeripheralPins.c>> const PinMap PinMap_SPI_SCLK[] = { {PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // ARDUINO {PB_0, SPI_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI5)}, // {PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, {PB_3, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {PB_10, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // {PB_12, SPI_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF7_SPI3)}, // Warning: also on NSS {PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // {PB_13, SPI_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI4)}, {PC_7, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, {PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, {NC, NC, 0} }; <</code>>
You might get it to work by importing the mbed-src instead of the mbed lib, then remove the comment for SPI4 SCLK and comment out SPI2's use of PB_13.