Skip to main content
HPATH.1
Associate III
April 14, 2025
Question

LL code generated by cubeMX not working for SPI - CubeMX 6.13.0 - STM32G070

  • April 14, 2025
  • 2 replies
  • 395 views

the below code generated by CubeMX. does not work.

I need to change the GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;     to  

GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;  to make it work.  

 

/* SPI1 init function */
void MX_SPI1_Init(void)
{

 /* USER CODE BEGIN SPI1_Init 0 */

 /* USER CODE END SPI1_Init 0 */

 LL_SPI_InitTypeDef SPI_InitStruct = {0};

 LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* Peripheral clock enable */
 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1);

 LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
 /**SPI1 GPIO Configuration
 PA1 ------> SPI1_SCK
 PA2 ------> SPI1_MOSI
 PA6 ------> SPI1_MISO
 */
 GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
 GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
 GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
 GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
 LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 GPIO_InitStruct.Pin = LL_GPIO_PIN_2;
 GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
 GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
 GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
 LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
 GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
 GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
 GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
 LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /* USER CODE BEGIN SPI1_Init 1 */

 /* USER CODE END SPI1_Init 1 */
 SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
 SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
 SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
 SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
 SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE;
 SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
 SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV256;
 SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
 SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
 SPI_InitStruct.CRCPoly = 7;
 LL_SPI_Init(SPI1, &SPI_InitStruct);
 LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
 LL_SPI_DisableNSSPulseMgt(SPI1);
 /* USER CODE BEGIN SPI1_Init 2 */

 /* USER CODE END SPI1_Init 2 */

}

 

SYSCLK  @ 64MHZ

HPATH1_0-1744623142833.png

 

 

 

 

 

 

 

 

 

 

2 replies

Technical Moderator
April 14, 2025

Hello @HPATH.1 

Thank you for your contribution.
This issue is currently under investigation. I will get back to you as soon as possible.

BR,

Souhaib

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.
Technical Moderator
April 18, 2025

Hello,

An internal ticket 208113 has been submitted to the dedicated team and I will keep you informed about any updates.

KR,

Souhaib

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.