Skip to main content
Volker Bremauer
Associate II
September 29, 2017
Solved

STM32H7 Bug in HAL_SPI_TransmitReceive ?

  • September 29, 2017
  • 2 replies
  • 1370 views
Posted on September 29, 2017 at 15:22

Is there a bug in the HAL driver lib FW 1.1.0 ?

Because SPI4 is not supported.

In the routine HAL_SPI_TransmitReceive there is a question

'if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance)) ...'

the else branch is empty/not existing.....

SPI4 is not a member of the HIGHEND instance !

#define IS_SPI_HIGHEND_INSTANCE(INSTANCE) (((INSTANCE) == SPI1) || \

                                           ((INSTANCE) == SPI2) || \

                                           ((INSTANCE) == SPI3))

Somebody has already used SPI4 ?

Is there a bug in the HAL lib, or have the prototyps of the H743 a bug in this section ?

    This topic has been closed for replies.
    Best answer by Imen.D
    Posted on November 08, 2017 at 15:13

    Hello

    Bremauer.Volker

    ,

    I confirm this is a bug.It seems that nothing is sent/received in case of SPI supporting only data transfer up to 16bits (SPI4 to SPI6 support up to 16-bit data mode).This issue is due to the wrong condition if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance)) in the case of 8 and 16-bit modes.

    Normally the condition IS_SPI_HIGHEND_INSTANCE should be applicable only for 32-bit mode (SPI1 to SPI3 support up to 32-bit data mode).

    So, I suggested to you modify:

    1- /* Transmit and Receive data in 32 Bit mode */

    if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance) && (hspi->Init.DataSize > SPI_DATASIZE_16BIT))

    2- For receiving data in 8 and 16 Bit modes, remove the condition if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance)).

    This issue will be fixed in the next release of STM32CubeH7.

    Thank you for highlighting this issue, and sorry for any inconvenience it may bring for you.

    Best Regards

    Imen

    2 replies

    ST Technical Moderator
    September 29, 2017
    Posted on September 29, 2017 at 17:58

    Hello

    Bremauer.Volker

    ,

    Thank you for you reported issue.I will check this issueandraise it internally if confirmed.

    I will keep you informed with updates.

    Kind Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Imen.DBest answer
    ST Technical Moderator
    November 8, 2017
    Posted on November 08, 2017 at 15:13

    Hello

    Bremauer.Volker

    ,

    I confirm this is a bug.It seems that nothing is sent/received in case of SPI supporting only data transfer up to 16bits (SPI4 to SPI6 support up to 16-bit data mode).This issue is due to the wrong condition if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance)) in the case of 8 and 16-bit modes.

    Normally the condition IS_SPI_HIGHEND_INSTANCE should be applicable only for 32-bit mode (SPI1 to SPI3 support up to 32-bit data mode).

    So, I suggested to you modify:

    1- /* Transmit and Receive data in 32 Bit mode */

    if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance) && (hspi->Init.DataSize > SPI_DATASIZE_16BIT))

    2- For receiving data in 8 and 16 Bit modes, remove the condition if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance)).

    This issue will be fixed in the next release of STM32CubeH7.

    Thank you for highlighting this issue, and sorry for any inconvenience it may bring for you.

    Best Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Yang Yu
    Visitor II
    November 21, 2017
    Posted on November 21, 2017 at 12:46

    I also find this bug today. It spent me a day to do with SPI4.

    I think it should be modified like this:

    if (hspi->Init.DataSize > SPI_DATASIZE_16BIT)

    {

        if (IS_SPI_HIGHEND_INSTANCE(hspi->Instance))

        {

        }

    }

    Another question: When will the new issue be published?

    Thank you !