AnsweredAssumed Answered

STM32CubeMX, SPI and assert

Question asked by Barta.Hank on Apr 9, 2015
Latest reply on Apr 14, 2015 by Amel N
This came up on the first code generation following the upgrade from 4.6/1.4 to 4.7/1.5. On subsequent code generation it did not happen so I thought it was an upgrade related glitch. However it returned on my most recent code generation. The problem seems to relate to not using CRC calculation. The generated code does not initialize the CRCPolynomial
/* SPI2 init function */
void MX_SPI2_Init(void)
  hspi2.Instance = SPI2;
  hspi2.Init.Mode = SPI_MODE_MASTER;
  hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi2.Init.NSS = SPI_NSS_SOFT;
  hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLED;

However the parameter is checked later:
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi)
  /* Check the SPI handle allocation */
  if(hspi == NULL)
    return HAL_ERROR;
  /* Check the parameters */
//  assert_param(IS_SPI_CRC_POLYNOMIAL(hspi->Init.CRCPolynomial));

Note that I have commented the offending line. I did not check to see what was there when this did not crop up.