2022-09-21 11:07 PM
uC: STM32H725AEIx
FW-Package: STM32Cube FW_H7 V1.10.0
CubeMX-Version: 6.6.1
IOC-File: Attached (SPI_bug.ioc)
I tried to generate code with CubeMX for my project. I set up SPI2 as Full-Duplex Master without hardware NSS with the follwing pin config:
The code generated in `void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)` looks like the following for MOSI and MISO:
GPIO_InitStruct.Pin = SPI_MISO_Pin|SPI_MOSI_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
Although it should look like that:
GPIO_InitStruct.Pin = SPI_MISO_Pin|SPI_MOSI_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
=> The configuration for `Alternate` is missing!
With the generated code, the MOSI and MISO lines do not work at all, while the SCK is doing its thing. After the fix they work like a charm.
Solved! Go to Solution.
2023-03-07 12:34 AM
Hello @Florian Moser
I am glad to inform you that the Internal ticket number: 135607 is fixed and integrated in the latest CubeMX version 6.8.0 .
This is the LINK for downloading it .
Thanks again for your contributions .
Ghofrane.
2022-09-26 08:27 AM
Hi @Florian Moser
uC: STM32H725AEIx
FW-Package: STM32Cube FW_H7 V1.10.0
CubeMX-Version: 6.6.1
I created a project where i activated the SPI2 only (same configuration as you ) to make sure of the existence of the issue that you mentioned before ; i checked the function "HAL_SPI_MspInit" and i found The configuration for `Alternate`
Kind regards
Ghofrane
2022-09-26 10:14 PM
Thanks for your response!
It generated it for PD3 and PC1, but not for PC2 in your case.
Please try using the same GPIO as me and you will more likely run into that bug:
2022-09-27 01:25 AM
2022-09-27 01:33 AM
Thank you for reproducing!
That's exactly the bug I am describing.
For PC2 and PC3 following line is missing in the CubeMX-generated code:
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
(Should be between lines 116 and 117 in your screenshot code)
Without that line, the MOSI pin isn't working, it just stays low.
Hope this bug get's fixed soon!
2022-09-28 02:25 AM
Hi @Florian Moser
Thank you for your contributions and for your detailed explanations,
I confirm the issue on my side, it has been reported to STM32CubeMX development team .
Internal ticket number: 135607(This is an internal tracking number and is not accessible or usable by customers).
I will keep you posted with updates.
Regards,
Ghofrane
2022-09-28 11:08 PM
Thank you very much!
2023-03-07 12:34 AM
Hello @Florian Moser
I am glad to inform you that the Internal ticket number: 135607 is fixed and integrated in the latest CubeMX version 6.8.0 .
This is the LINK for downloading it .
Thanks again for your contributions .
Ghofrane.
2023-03-07 10:27 PM
Nice, thank you!