Missing alternate function on SPI-Pins in CubeMX-generated-code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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:
- SCK: PB13
- MISO: PC2
- MOSI: PC3
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.
- Labels:
-
Bug-report
-
SPI
-
STM32CubeMX
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-26 8: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
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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:
- SCK: PB13
- MISO: PC2
- MOSI: PC3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-27 1:25 AM
Hi @Florian Moser​
I reproduced the configuration using the same GPIO as you said
- SCK: PB13
- MISO: PC2
- MOSI: PC3
I found this :
Please have a look .
Kind regards
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-27 1: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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-28 2: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
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-28 11:08 PM
Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-07 10:27 PM
Nice, thank you!
