cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H5 SPI gets disabled by HAL after each transfer

miladmohtashamirad
Associate III

Hi. 
I'm trying to use STM32H573IIKxQ's SPI using HAL.
I've noticed that the HAL library disables the SPI after each transfer which causes the SCK pin to go high and goes low again before the next transfer, which causes an extra bit being shifted to the slave device:

miladmohtashamirad_0-1728965399066.png

I tried to remove the line from HAL lib that disables SPI after finishing the transfer which cause the next transfers to not happening. 
is there any solution for this? I mean is it possible to keep SPI enabled the whole time and then use it in different manners (pulling, IT, DMA, single byte transfer, ...) ?
Thank you.

Here is the part of the code that I'm trying:

 

    spi_busy=1;
    HAL_SPI_Transmit_DMA(&hspi2,buff,130);
    while(spi_busy);
    spi_busy=1;
    HAL_SPI_Transmit_DMA(&hspi2,buff+40,80);
    while(spi_busy);
    HAL_SPI_TransmitReceive(&hspi2,buff+10,buff+5,3,20);
    HAL_Delay(1);
    spi_busy=1;
    HAL_SPI_Transmit_DMA(&hspi2,buff+140,30);
    while(spi_busy);
    HAL_Delay(1);
    HAL_SPI_TransmitReceive(&hspi2,buff+15,buff+5,3,20);
    HAL_Delay(1);
    HAL_SPI_TransmitReceive(&hspi2,buff+10,buff+5,3,20);
    HAL_Delay(1);
    spi_busy=1;
    HAL_SPI_Transmit_DMA(&hspi2,buff+140,30);
    while(spi_busy);
    HAL_Delay(1);
    HAL_SPI_TransmitReceive(&hspi2,buff+15,buff+5,3,20);
    HAL_Delay(1);

 

 

1 REPLY 1
Petr Sladecek
ST Employee

Hello,

pls apply AF control (AFCNTR bit) which just prevents such a signals toggle when SPI is disabled.

Rgds,

Petr