Author Topic: Can STM32 MCU SPI master clock frequency be 'odd' number  (Read 231 times)

0 Members and 1 Guest are viewing this topic.

Online Wilson__Topic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: gb
Can STM32 MCU SPI master clock frequency be 'odd' number
« on: May 17, 2024, 10:29:28 am »
Can STM32 SPI frequency be a random number, like 12,345,678Hz (subject to rounding resolution of the prescaler divider N)?

To optimize highest transfer speed between MCU and sensor, finish the task and back to sleep for minimum cell energy.

Presumably, we can ramp up SPI speed until error, then, scale back nnn% for margin.

Many thanks
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 1818
  • Country: au
Re: Can STM32 MCU SPI master clock frequency be 'odd' number
« Reply #1 on: May 17, 2024, 10:51:41 am »
Since it is the Master that provides the bit clock it can, within reason, be whatever you like as long as timing constraints are adhered to and the Slave devices can run at that clock.
 
The following users thanked this post: Wilson__

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3916
  • Country: nl
Re: Can STM32 MCU SPI master clock frequency be 'odd' number
« Reply #2 on: May 17, 2024, 11:00:50 am »
It depends on the main clock, the SPI baud rate control settings and the MCU in use, but within these parameters it can be whatever you like.

Offline S. Petrukhin

  • Super Contributor
  • ***
  • Posts: 1270
  • Country: ru
Re: Can STM32 MCU SPI master clock frequency be 'odd' number
« Reply #3 on: May 17, 2024, 11:34:41 am »
The correct solution is to choose frequency that sensor datasheet suggests.
You can take risks - this will not lead to failure, there will just be a loss of communication or errors.

In STM32, the CLK frequency in SPI is specified as a divider, you cannot select the frequency, but you can turn the SysCLK.

« Last Edit: May 17, 2024, 11:38:19 am by S. Petrukhin »
And sorry for my English.
 
The following users thanked this post: Wilson__


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf