cancel
Showing results for 
Search instead for 
Did you mean: 

How to change SPI module baud rate at run time

HPate.10
Associate III

Hello Support Team,

Currently, I am working on the STM32H745-Disc board.

In that, I have used the SPI2 module and I have also configured the baud rate as a 3Mbit/s using the STM32CubeMX configuration tool and generated code for the same. (SPI Init done Inside the main() function)

Now, I need to change the SPI2 module baud rate to 12Mbit/s from 3Mbit/s baud rate at run time.

Please suggest any API or an appropriate way for the above scenario.

Thanks In Advance.

2 REPLIES 2
Piranha
Chief II

The HAL doesn't have such API.

Bob S
Principal

As long as the SPI port is idle, you can change the baud rate bits. Either reading/writing directly to the register (CR1, at least in the G4/F4 series, don't know about the H7), or perhaps look at the HAL LL functions if you want a wrapper around the direct register writes. You'll need the H7 reference manual, if you don't already have a copy.