cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H573 SPI clock not working

A_Bit_More
Associate II

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 :
 

A_Bit_More_0-1736980651955.png

 



1 ACCEPTED SOLUTION

Accepted Solutions
A_Bit_More
Associate II

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.

Solution for getting SPI2 to work:
I created a new project from the stm32cubemx, and my first setup was to only setup spi2. 
I set the Data Size to 8 bits (can keep at default of 4 bits just update the logic analyzer setup) and the prescaler to 32 (which sets the baudrate to 7.8125 MBits/s)

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:
    • 01196986-477e-4afb-912e-981c4012963d.png

Other steps I took to try and to get spi5 and spi2 working: 
Original situation: I have the logic analyzer connected to the devkit and I am using the stmod+ extension. Image added at the bottom. 
  • 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
  • 40f9d808-a40c-427a-9856-87248d1694e9.jpg

View solution in original post

7 REPLIES 7

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?

Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

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.

Hi Imen.D

I'm not using PB13 or PB14.

Currently I'm using the default configs for the clock:

A_Bit_More_2-1737056500317.pngA_Bit_More_3-1737056522554.png


the pins I'm using: 
for spi2 is 

A_Bit_More_0-1737056374460.png

and for spi5 is : 

A_Bit_More_1-1737056415144.png

 

Read out and check/post content of SPI and relevant GPIO registers.

JW

A_Bit_More
Associate II

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.

Solution for getting SPI2 to work:
I created a new project from the stm32cubemx, and my first setup was to only setup spi2. 
I set the Data Size to 8 bits (can keep at default of 4 bits just update the logic analyzer setup) and the prescaler to 32 (which sets the baudrate to 7.8125 MBits/s)

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:
    • 01196986-477e-4afb-912e-981c4012963d.png

Other steps I took to try and to get spi5 and spi2 working: 
Original situation: I have the logic analyzer connected to the devkit and I am using the stmod+ extension. Image added at the bottom. 
  • 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
  • 40f9d808-a40c-427a-9856-87248d1694e9.jpg
A_Bit_More
Associate II

For Future Reference: SPI2 is good to use with this settings and to Avoid using SPI5

Make sure Clock speed is 250MHz and peripheral clock speed is 250MHz
  • 95dbc3bb-1238-403e-b4e1-5dac5378d260.png

These are the configurations for SPI2: Mode Master full-duplex
  • set the datasize to 8 bits and prescaler to 32 to have a baudrate of 7.8125 MBits/s
  • 27ab493e-c4e4-468c-8a62-6098b34ab223.png