NUCLEO-F429ZI SPI pin defintions are wrong

Post here first, or if you can't find a relevant section!
Post Reply
phil bowles
Posts: 13
Joined: Mon May 25, 2020 10:15 am

NUCLEO-F429ZI SPI pin defintions are wrong

Post by phil bowles »

I'm interfacing an SPI SD reader, since the SDIO examples won't compile. The good news is that I have TWO connected successfully on SPI1 and SPI3. The bad news is that I was only able to do that after I realised that the SPI pin defnitions in
...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) {}
With my defintions, the output is as follows:

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
and using those pins allows both SD cards to work on SPI1 and SPI3

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
Which are clearly wrong and result in neither SPI port functioning.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: NUCLEO-F429ZI SPI pin defintions are wrong

Post by fpiSTM »

phil bowles
Posts: 13
Joined: Mon May 25, 2020 10:15 am

Re: NUCLEO-F429ZI SPI pin defintions are wrong

Post by phil bowles »

It has NOT been answered there, it has been avoided there. The first answer given was clearly incorrect, and I provided a link to the ST website using your own documentation that proved it was incorrect. For some reason, that evidence seems to have disappeared and there is a second incorrect answer stating the same as the first which even a beginner can see is absolutely 100% incorrect, proved by your own documentation!

Both incorrect answers stated: "PD14 has no SPI capabilities", so how then do you explain this:

Image

AND that when I use PD14 it works and when I use any other value suggested in the two incorrect answers, it does not work

What better defintion of incorrect" can there be? Your own documentation is telling you that you are wrong, how much more evidence do you need?
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: NUCLEO-F429ZI SPI pin defintions are wrong

Post by fpiSTM »

phil bowles wrote: Mon Jul 13, 2020 3:47 pm What better defintion of incorrect" can there be? Your own documentation is telling you that you are wrong, how much more evidence do you need?
I've answered you on GitHub, seems an issue in the ST datasheet. :mrgreen:
Post Reply

Return to “General discussion”