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
ZacckOsiemo
ZacckOsiemo5mo ago
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
ZacckOsiemo
ZacckOsiemo5mo ago
Seems to only be an issue for SPI1
Boss lady
Boss lady5mo ago
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
ZacckOsiemo
ZacckOsiemo5mo ago
Yes that's all the standard stuff it works with SPi2 & 3, as you see above to get spi1 you need i2s disabled.
UC GEE
UC GEE5mo ago
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
ZacckOsiemo
ZacckOsiemo5mo ago
I don't think you understood my issue SPI is working, SPI1 wasn't
Marvee Amasi
Marvee Amasi5mo ago
Hi @ZacckOsiemo have you been able to set up the Cr1 of SPI1 on your STM32F407-DISC1 ?
ZacckOsiemo
ZacckOsiemo5mo ago
yeap for SPI1 you need to disable I2S that's the audio peripheral.
Want results from more Discord servers?
Add your server