cancel
Showing results for 
Search instead for 
Did you mean: 

L432KC (Nucleo) unwanted connection between PB6, SPI1 and SPI3

Volker Kible
Associate
Posted on July 12, 2018 at 17:19

Hi folks,

Board: STM32L432KC Nucleo

IDE: Atollic TrueSTUDIO� for STM32 9.0.0

I am using SPI1 as slave and SPI3 as master, both full duplex, DMA mode, in separate communication setups (different time scales). I tested the function as well in circuit as with a function generator and logic analyzer.

When PB6 is unconfigured (so, probably an input), all works fine, SPI1 is transmitting data when an external clock is applied and NSS is low. SPI3 also works fine as a master in this case (both TX and RX).

BUT when PB6 is configured as output (Push-Pull in this case), SPI1 does not transmit data via PA6 (MISO) anymore.

Instead, the state of PA6 seems to reflect the state of PB6. Vice versa, PB6 seems to reflect PA6 any time, also when unconfigured.

Strange enough, when PB6 is set to high state, it does not remain high, but pulses with the SPI3 SCK signal. Also, when SPI3 MOSI has a low to high transition, the following SCK low pulse in PB6 and PA6 is missed out (the signal stays high for one clock cycle).

When PB6 is set low, it stays low and PA6 also stays low.

The program is quite barebone and does only contain what is necessary to transmit data via SPI1 and SPI3, and to configure PB6. I am using the HAL (STM32Cube_FW_L4_V1.11.0). The only difference between working and not working state is the config of the PB6 pin:

GPIO_InitStruct2.Pin = GPIO_PIN_6;

GPIO_InitStruct2.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct2.Pull = GPIO_NOPULL;

GPIO_InitStruct2.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct2);

GPIO_InitStruct2 is not used anywhere else in the code.

Here are the other Pin configs:

GPIO_InitStruct1.Pin = SPI3_SCLK_Pin|GPIO_PIN_5|SPI3_MISO_NRDY_Pin;

GPIO_InitStruct1.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct1.Pull = GPIO_NOPULL;

GPIO_InitStruct1.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct1.Alternate = GPIO_AF6_SPI3;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct1);

HAL_GPIO_WritePin(SPI3_SSEL_GPIO_Port, SPI3_SSEL_Pin, GPIO_PIN_SET);

GPIO_InitStruct1.Pin = SPI3_SSEL_Pin;

GPIO_InitStruct1.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct1.Pull = GPIO_NOPULL;

GPIO_InitStruct1.Speed = GPIO_SPEED_FREQ_MEDIUM;

HAL_GPIO_Init(SPI3_SSEL_GPIO_Port, &GPIO_InitStruct1);

GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_6|GPIO_PIN_7;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL; //GPIO_PULLDOWN

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

// Configure NSS pin as alternate function 5 (SPI1) like all the pins before

GPIO_InitStruct.Pin = SPI1_NSS_Pin;

HAL_GPIO_Init(SPI1_NSS_GPIO_Port, &GPIO_InitStruct);

The pins used are as follows:

PA1: SPI1 SCK

PA6: SPI1 MISO

PA7: SPI1 MOSI

PB0: SPI1 NSS

PA12: SPI3 SSEL

PB3: SPI3 SCK

PB4: SPI3 MISO

PB5: SPI3 MOSI

PB6: desired use as output PP

I will attach some logic analyzer screens.

Has anyone experienced something similar or knows what could be the reason?

If desired, i will attach the SPI configuration later, but i believe that this does not have a lot of influence on the problem.

It looks more like a pin mapping problem.

Have a nice evening - V

#hal-spi #spi3 #spi1 #connection #pb6
1 REPLY 1
Volker Kible
Associate
Posted on July 13, 2018 at 10:34

Hi folks,

That was a typical RTFM problem... there is a solder bridge between PA6 and PB6 on the Nucleo-L432KC. Shit. 🙂

0690X0000060MAZQA2.png

(can be found in the Nucleo-32 user manual UM1956)

Have a nice day!

Volker