STM32H573 SPI clock not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-15 2:41 PM
I am following a basic example from stm32: Getting started with SPI - stm32mcu
I follow the steps for setting up SPI master with polling (Blocking mode). I did make sure to select the board STM32H573 DK instead of the one listed in the example.
I initially used SPI5, however it wouldn’t transmit anything and its clock was always high.
Then I switched to using SPI2, however it was always stuck low.
Any insight would be appreciated.
I connected a logic analyzer and here is an image of this :
Solved! Go to Solution.
- Labels:
-
STM32H5 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-17 8:50 AM
Update of the day: I was able to get SPI2 to work and still no success with getting SPI5 to work. I will continue forward with SPI2.
Notes:
- the system clock is set to max by default 250MHz
- The peripheral clock is set to the max by default as well of 250MHz
- Setting the prescaler to 32 -256 works great no issue, however when setting to a smaller value nothing transmits.
- would like to note that C is detected in the image below which is not expected (I will need to check if this is due to also using SPI5).
- In the same project I tried to setup spi5, however regardless of the prescaler value nothing would transmit over the lines.
- An image of the output for both spi2 and spi5:
- I had initialized spi5 first with an interrupt enable and tested it alone, but with no progress getting it to transmit. I then setup SPi2 on the same project. Result: no success getting it to transmit either.
- I then proceeded to change the SPI5 setup from having interrupt enable to disable, to test only polling. Result: no success getting it to transmit.
- I then proceeded to change the SPI gpio pins for Maximum output speed to very high (originally at low). Result: no success getting it to transmit.
- then I proceeded to disable spi5 and continue testing with just spi2, I setup RCC and changed the HSE and LSE to use the Crystal/ceramic resonator. Result: no success, in transmitting.
- then I proceeded to cross examine my project with the example from stm32H7 for SPI. No main difference, everything looked to be setup correctly, nothing was missing on my end.
- I also posted this issue on the stm32 forum and got two responses: link to post: STM32H573 SPI clock not working - STMicroelectronics Community
- 1: check if the pins are being used by other components
- The pins weren't being used by another component and were free to use. Will note that the SPI5 pins had an extension/fan-out board to easily connect.
- 2: check the SPI clock pins max output for PB13 and PB14.
- I checked the SPI2 and SPI5 pins but I wasn't using those pins listed. I did change the prescaler for both SPIs but no noticeable difference was made.
- i tried clearing out all the pin configuration and board, and then setup just spi 2. Result: no success in transmitting.
- I was renaming my project example and lost access to the project, so I created a new project and setup only spi2 and changed the prescaler to 64, and it worked =)
- Image of setup for spi5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-15 2:44 PM
Are you sure those pins aren't occupied by something else on the board?
Check with the User Manual and/or Schematics
Can you toggle the pins when they're just in GPIO output mode?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-16 1:08 AM
Hello @A_Bit_More ,
Please check this article includes SPI characteristics and clarification of maximum clock frequency for STM32H5 devices: SPI maximum clock frequency for STM32H5 MCUs devices when using PB13 and PB14 I/Os
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-16 8:30 AM - edited 2025-01-16 8:33 AM
Hi Andrew!
The only mode for the pin is Alternative Function PP and I have been able to set it high through STM32CubeMX.
This is the User Manual I'm following : attached below
For spi2 I don't see anything directly connected to it, other than it being an extension for arduino to connect.
For spi5, I don't see anything directly connected to it either, other than it having an extension for STMOD+.
- I also don't have anything connected to the pmod.
- I have the default configurations for the board so spi5 should be accessible
Note: there is a typo on Table 31, where it states some pins are for spi5, but they are really for spi2. You can verify with table 32.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-16 11:42 AM - edited 2025-01-16 12:14 PM
Hi Imen.D
I'm not using PB13 or PB14.
Currently I'm using the default configs for the clock:
the pins I'm using:
for spi2 is
and for spi5 is :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-16 2:19 PM
Read out and check/post content of SPI and relevant GPIO registers.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-17 8:50 AM
Update of the day: I was able to get SPI2 to work and still no success with getting SPI5 to work. I will continue forward with SPI2.
Notes:
- the system clock is set to max by default 250MHz
- The peripheral clock is set to the max by default as well of 250MHz
- Setting the prescaler to 32 -256 works great no issue, however when setting to a smaller value nothing transmits.
- would like to note that C is detected in the image below which is not expected (I will need to check if this is due to also using SPI5).
- In the same project I tried to setup spi5, however regardless of the prescaler value nothing would transmit over the lines.
- An image of the output for both spi2 and spi5:
- I had initialized spi5 first with an interrupt enable and tested it alone, but with no progress getting it to transmit. I then setup SPi2 on the same project. Result: no success getting it to transmit either.
- I then proceeded to change the SPI5 setup from having interrupt enable to disable, to test only polling. Result: no success getting it to transmit.
- I then proceeded to change the SPI gpio pins for Maximum output speed to very high (originally at low). Result: no success getting it to transmit.
- then I proceeded to disable spi5 and continue testing with just spi2, I setup RCC and changed the HSE and LSE to use the Crystal/ceramic resonator. Result: no success, in transmitting.
- then I proceeded to cross examine my project with the example from stm32H7 for SPI. No main difference, everything looked to be setup correctly, nothing was missing on my end.
- I also posted this issue on the stm32 forum and got two responses: link to post: STM32H573 SPI clock not working - STMicroelectronics Community
- 1: check if the pins are being used by other components
- The pins weren't being used by another component and were free to use. Will note that the SPI5 pins had an extension/fan-out board to easily connect.
- 2: check the SPI clock pins max output for PB13 and PB14.
- I checked the SPI2 and SPI5 pins but I wasn't using those pins listed. I did change the prescaler for both SPIs but no noticeable difference was made.
- i tried clearing out all the pin configuration and board, and then setup just spi 2. Result: no success in transmitting.
- I was renaming my project example and lost access to the project, so I created a new project and setup only spi2 and changed the prescaler to 64, and it worked =)
- Image of setup for spi5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-01-17 8:51 AM
For Future Reference: SPI2 is good to use with this settings and to Avoid using SPI5
- set the datasize to 8 bits and prescaler to 32 to have a baudrate of 7.8125 MBits/s
