Baud rate calculation for STM32WLE SPI2 in STM32CubeMX appears to be in error
When I configure SPI2 in STM32CubeMX, I see the following:
Here, I'm set up as a full-duplex SPI master, the prescaler is set to 8 and underneath the prescaler specification, it computes the baud rate to be 2 MBits/s. I've also observed that this value does not change with processor clock frequency so the tool must be assuming that the input clock is from the SPI2S2 clock multiplexor. This is consistent with what I see in STM32CubeMX because if I vary this clock with the PLL, the baud rate tracks this frequency. SPI1 works as expected
I ran some code that performs SPI transactions and observed the following on the logic analyzer:
Clearly, the SPI baud rate is 4 MBits/s and not the 2 MBits/s as computed by the tool.
From this, I conclude that the clock source for SPI is actually PCLK1 and not the output of the SPI2S2 clock multiplexor. I think that that clock is only used in I2S mode (which I've never used) which is suggested by the reference manual in section 7.4.29 for bits 9:8:
"This bit is set and cleared by software to select the SPI2S2 I2S clock source."
Is this a bug in STM32CubeMX or is there something fundamental that I'm missing?