Skip to main content
nichtgedacht
Associate III
February 13, 2017
Question

CubeMX STM32L433CC SPI bug?

  • February 13, 2017
  • 1 reply
  • 607 views
Posted on February 13, 2017 at 16:02

Hi

CubeMX 4.19 with STM32L433CCx selected generates the following code for SPI2

void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
{
 GPIO_InitTypeDef GPIO_InitStruct;
 if(spiHandle->Instance==SPI2)
 {
 /* USER CODE BEGIN SPI2_MspInit 0 */
 /* USER CODE END SPI2_MspInit 0 */
 /* Peripheral clock enable */
 __HAL_RCC_SPI2_CLK_ENABLE();
 
 /**SPI2 GPIO Configuration 
 PB13 ------> SPI2_SCK
 PB14 ------> SPI2_MISO
 PB15 ------> SPI2_MOSI 
 */
 GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
 GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 /* USER CODE BEGIN SPI2_MspInit 1 */
 /* USER CODE END SPI2_MspInit 1 */
 }
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Because PB14 is MISO, GPIO_MODE_AF_PP is wrong. This the default.

When trying to correct this in 'Configuration' the only choice is this setting. Input Mode for MISO is not offered in drop down box. Further more when touching this drop down box the setting becomes marked as modified.

Dieter

    This topic has been closed for replies.

    1 reply

    Nesrine M_O
    Associate
    February 13, 2017
    Posted on February 13, 2017 at 16:50

    Hi

    Br_ggemann.Dieter

    ,

    Please refer to

    pin definitions on

    your related datasheet.

    Also I recommend you to have a look to SPI examples under the STM32L4 package to have idea about SPI pins configuration :

    STM32Cube_FW_L4_V1.5.0\Projects\STM32L432KC-Nucleo\Examples\SPI

    -Nesrine-