STM32F446RE CubeMX HAL-SPI Problem
Hello,
I habe a two problems with the SPI-communication between a Nucleo64 and a X-Nucleo-IHM01A1 => STM32F446RE to L6474.
1. The CubeMx 4.15 creates following code in the �void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
�**SPI1 GPIO Configuration
PA5------> SPI1_SCK PA6------> SPI1_MISO PA7------> SPI1_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; 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_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); �.} Why GPIO_PIN_6 (= MISO) is defined as an output? I think it should be an input!?(I tried this also with other F4xx, F3xx and F7xx => all the same. It's already shown in the
CubeMX->Configuration->SPI-Settings->GPIO-Settings
and can&sharpt be changed. Funny thing: Creating project for a STM32F103RBT6 => MISO is an input!!So I modified the void HAL_SPI_MspInit to:
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
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_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP; // (also tried NOPULL)
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; // should be obsolent
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
With this Init and HAL_SPI_Transmit I can send bytes to the L6474 (Stepper Controller).
With my analyzer I can see, that the L6474 sends the correct response-bytes.
I try to read it with:
if(HAL_SPI_TransmitReceive(&hspi1, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, 1, 1000) != HAL_OK)
{ Error_Handler(); }
The aTxBuffer is loaded with 0x00 for clocking the SCK
�but the aRxBuffer is always empty.(0x00).
Where is the (my?) mistake?The input-hardware should be fine � I can read a signal if I define Pin6 as a simple GPIO-input.
Thanks for your ideas
Sven
#cubemx-stm32f446-hal_spi