Skip to main content
Jos Poelmans
Associate II
September 4, 2018
Question

stm32cubeMx generate LL init function void MX_SPI2_Init(void) but th e function is not correct in slave mode.

  • September 4, 2018
  • 2 replies
  • 1009 views

first line in function MX_SPI2_Init()

 LL_SPI_InitTypeDef SPI_InitStruct; is not filled with zero's

and baudrate is not set for slave mode.

But in in funtion LL_SPI_Init baurate is filled in an the destruct SPI CR1 register.

I have there fore init the struct to zero and then there is no moer problem

 LL_SPI_InitTypeDef SPI_InitStruct = {0};

This topic has been closed for replies.

2 replies

Jos Poelmans
Associate II
September 4, 2018

See in question ther is an answer for the problem.

I hope the Stm32cubeMx will look to the problem en generate in a new version

a better code.

Amel NASRI
Technical Moderator
September 4, 2018

Hi @Jos Poelmans​ ,

I am using STM32CubeMX 4.26.1 with STM32L052R6Hx, and I see baudrate field initiated as following in MX_SPI2_Init:

SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;

This is the default configuration when enabling SPI2.

Are we using different CubeMX versions? Which device did you selected? May be if you can share a .ioc file.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.