Does anyone know if there are any special steps to using SPI1 on the STM32F407-DISC1 board?
Does anyone know if there are any special steps to using SPI1 on the STM32F407-DISC1 board. Specifically I am trying to interface with the onboard MEMS accelerometer. At the moment I have code that works for SPI2 and SPI3. Whenever I try to initialize SPI1 its RCC clock is enabled but the Cr1 of SPI1 is never set up.
8 Replies
So I walked through a HAL example and noticed they were touching the i2scfgr, basically disabling it.
If I do the same as such
//use SPI mode
pSPIHandle->pSPIx->I2SCFGR &= ~(1 << SPI_I2SCFGR_I2SMOD_Pos);
It seems to work
Seems to only be an issue for SPI1
firstly you have to initialize the SPI1 peripheral by configuring its registers. Set the CR1 register to specify the desired settings for the SPI mode, data format, clock polarity, and clock phase. You can refer to the reference manual of the STM32F407-DISC1 board for more details on the available configuration options, and also enable the SPI1 peripheral by setting the SPE bit in the CR1 register. This enables the SPI1 interface and allows data transfer to occur.
this should set up ur cr1 of SPI1
Yes that's all the standard stuff it works with SPi2 & 3, as you see above to get spi1 you need i2s disabled.
Try to enable the clock for SPI1 and the GPIO ports in the RCC (Reset and Clock Control) registers.
Then,If you are using DMA, configure the DMA channels for SPI1 Tx and Rx.
Give it a try @ZacckOsiemo
I don't think you understood my issue SPI is working, SPI1 wasn't
Hi @ZacckOsiemo have you been able to set up the Cr1 of SPI1 on your STM32F407-DISC1 ?
yeap for SPI1 you need to disable I2S that's the audio peripheral.