2021-07-21 06:42 AM
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
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
Solved! Go to Solution.
2021-08-05 10:26 AM
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.
2021-07-29 10:07 AM
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.
2021-08-04 01:32 AM
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.
2021-08-05 02:19 AM
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.
2021-08-05 10:26 AM
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.