cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB - STM32Cube SAI HAL code generation bug

DeonT
Associate

Hi,

I found a possible bug in the "stm32wbxx_hal_msp.c" file when using Cube in the STM32CubeIDE to enable the SAI peripheral.

I did not test all the combinations, but have mine set up as follows:

SAI A - Async Slave

SAI B - Sync Slave

0693W00000D0ERXQA3.jpg 

The bug is that the the code does not include and set the "Alternate" member of the GPOI_InitStruct for SAI Block A and B

The generated code is:

/**SAI1_A_Block_A GPIO Configuration
PA8     ------> SAI1_SCK_A
PA9     ------> SAI1_FS_A
PA10     ------> SAI1_SD_A
*/
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

and

/**SAI1_B_Block_B GPIO Configuration
PA5     ------> SAI1_SD_B
*/
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

But it should be:

    /**SAI1_A_Block_A GPIO Configuration
    PA8     ------> SAI1_SCK_A
    PA9     ------> SAI1_FS_A
    PA10     ------> SAI1_SD_A
    */
    GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
    GPIO_InitStruct.Alternate = GPIO_AF13_SAI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    /**SAI1_B_Block_B GPIO Configuration
    PA5     ------> SAI1_SD_B
    */
    GPIO_InitStruct.Pin = GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
    GPIO_InitStruct.Alternate = GPIO_AF13_SAI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

I'm using:

STM32CubeIDE V1.6.1

STM32CubeMX V6.2.1-RC2

with

STM32Cube FW_WB V1.11.1

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @DeonT​ ,

Thanks for your preempt reply and for attaching your project. Actually you're right, I've been able to reproduce the issue using STM32WB35CEUxA MCU even with the latest STM32CubeMX version 6.3.0.

This misbehavior will be reported internally to be fixed. I'll keep you posted with the updates.

Sorry for any inconvenience that this may cause.

Even though this reply doesn’t directly solve the issue, I’m marking it as Best, since it will help clarify the current situation for other customers with the same question. I will post an update here once the issue has been fixed.

Thanks for your contribution.

Khouloud.

View solution in original post

4 REPLIES 4

Hello @DeonT​ ,

Please excuse the somewhat late reply and thank you for having reported.

Actually, I wasn't able to reproduce any issue from my side, and GPIO_InitStruct.Alternate = GPIO_AF13_SAI1; is correctly generated.

Could you please attach your .ioc file for further check ?

Thanks in advance,

Khouloud.

Hi @DeonT​ ,

I want to come back to this topic to check if you are always reproducing the issue. Is the generated STM32CubeMx code always missing the GPIO_InitStruct.Alternate ?

Could you please re-test with the latest STM32CubeMX version 6.3.0 and see if the problem still occurs.

Your feedback is important to track the the root cause of the problem.

Khouloud.

DeonT
Associate

Hi @Khouloud OTHMAN​ ​ ​ ,

Yes, every time CubeMX generates the code after a change, the GPIO_InitStruct.Alternate code is removed.

Unfortunately I cannot test it with version 6.3.0 just yet, since I'm in the middle of a project and don't want to update the software until we reach the next milestone.

I have attached the ioc file for you.

Hi @DeonT​ ,

Thanks for your preempt reply and for attaching your project. Actually you're right, I've been able to reproduce the issue using STM32WB35CEUxA MCU even with the latest STM32CubeMX version 6.3.0.

This misbehavior will be reported internally to be fixed. I'll keep you posted with the updates.

Sorry for any inconvenience that this may cause.

Even though this reply doesn’t directly solve the issue, I’m marking it as Best, since it will help clarify the current situation for other customers with the same question. I will post an update here once the issue has been fixed.

Thanks for your contribution.

Khouloud.