...Arduino15\packages\STM32\hardware\stm32\1.9.0\variants\NUCLEO_F429ZI\PeripheralPins.c
bear no resemblance whatsoever to the pin defintions given in the datasheet.
I provided my own replacements in the sketch, copying the values from the datasheet and everything works perfectly. Without them nothing works at all. Are they a "cut and paste" error from a different MCU ? How anyone has ever used hardware SPI on this board is beyond me.
Code: Select all
// If you omit these the results are total garbage
const PinMap PinMap_SPI_MOSI[] = {
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
{NC, NP, 0}
};
const PinMap PinMap_SPI_MISO[] = {
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // - D12
{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
{NC, NP, 0}
};
const PinMap PinMap_SPI_SCLK[] = {
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, // - D13
{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
{NC, NP, 0}
};
const PinMap PinMap_SPI_SSEL[] = {
{PD_14, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
{NC, NP, 0}
};
void showSPIpins(void* peripheral){
PinName x;
x=pinmap_pin(peripheral,PinMap_SPI_MOSI);
Serial.printf("MOSI=%d or D%d\n",x,pinNametoDigitalPin(x));
x=pinmap_pin(peripheral,PinMap_SPI_MISO);
Serial.printf("MISO=%d or D%d\n",x,pinNametoDigitalPin(x));
x=pinmap_pin(peripheral,PinMap_SPI_SCLK);
Serial.printf("SCLK=%d or D%d\n",x,pinNametoDigitalPin(x));
x= pinmap_pin(peripheral,PinMap_SPI_SSEL);
Serial.printf("SSEL=%d or D%d\n",x,pinNametoDigitalPin(x));
}
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.printf("\nPIN assignments for SPI1\n");
showSPIpins(SPI1);
Serial.printf("\nPIN assignments for SPI3\n");
showSPIpins(SPI3);
}
void loop(void) {}
Code: Select all
PIN assignments for SPI1
MOSI=7 or D11
MISO=6 or D12
SCLK=5 or D13
SSEL=62 or D10
PIN assignments for SPI3
MOSI=21 or D22
MISO=20 or D25
SCLK=19 or D23
SSEL=4 or D24
Without my defintions i.e. using the wrong defaults from Peripherals.c, the output is:
PIN assignments for SPI1
Code: Select all
MOSI=7 or D11
MISO=6 or D12
SCLK=5 or D13
SSEL=4 or D24
PIN assignments for SPI3
MOSI=21 or D22
MISO=43 or D46
SCLK=19 or D23
SSEL=15 or D20