cancel
Showing results for 
Search instead for 
Did you mean: 

changing SPI-settings ends up in HAL-Timeout

Lukas1
Associate III

Hi,

I have to change the CPOL and CPHA of SPI, because I'm communicating with different SPI-Devices. This worked fine on a Nucleo-Board with a Cortex M7.

On the Cortex M4 of the STM32MP157-DK2 it ends up in HAL-Timeout :(

After some time I found a solution.

I added this in front of the code changing the SPI-settings:

HAL_SPI_DeInit(&hspi5);
HAL_SPI_Init(&hspi5);
 
/** code to change settings of CPOL und CPHA **/

Now it works perfectly fine 🙂

My question is now: why?

regards

Lukas

1 ACCEPTED SOLUTION

Accepted Solutions
PatrickF
ST Employee

Hi,

You did not mention how do you change the settings ?

HAL initialization are usually not intended to be issue more than one time, so it is recommended to use DeInit() as you mention.

in STM32MP15x Reference Manual, it is clearly stated you cannot change CPOL/CPHA once the SPI is enabled.

           Note: Prior to changing the CPOL/CPHA bits the SPI must be disabled by resetting the SPE bit.

You can also directly play with IP registers (if you see this as allowed according to Reference Manual).

You have many SPI related fonctions in stm32mp1xx_ll_spi.h (e.g. LL_SPI_Disable(), LL_SPI_SetClockPolarity(), LL_SPI_SetClockPhase(), LL_SPI_Enable(), etc...).

Cortex-M7 device you mention likely uses different SPI and SW versions, so I have no explanation why it was working (have you checked the related Reference Manual ?)

In order 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.

View solution in original post

1 REPLY 1
PatrickF
ST Employee

Hi,

You did not mention how do you change the settings ?

HAL initialization are usually not intended to be issue more than one time, so it is recommended to use DeInit() as you mention.

in STM32MP15x Reference Manual, it is clearly stated you cannot change CPOL/CPHA once the SPI is enabled.

           Note: Prior to changing the CPOL/CPHA bits the SPI must be disabled by resetting the SPE bit.

You can also directly play with IP registers (if you see this as allowed according to Reference Manual).

You have many SPI related fonctions in stm32mp1xx_ll_spi.h (e.g. LL_SPI_Disable(), LL_SPI_SetClockPolarity(), LL_SPI_SetClockPhase(), LL_SPI_Enable(), etc...).

Cortex-M7 device you mention likely uses different SPI and SW versions, so I have no explanation why it was working (have you checked the related Reference Manual ?)

In order 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.