This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPI on STM32F407 Discovery not working

I am trying to program an F407VG manually without using CubeMX and using registers. Could someone please help me get the SPI running? When I look on an oscilloscope, the Slave/Chip select goes low and high correctly but I am writing data to SPI1 DR and I don't see anything on MOSI or SCLK. What have I done wrong? C code below:

When running the code I set the CS pin to low and then write random data to the SPI1 DR like this:

GPIOE->BSRR |= (0<<5);
Delay by 10000
SPI1->DR |= (1<<7) | (1<<2);

Delay by 50
SPI1->DR |= (0<<7) | (0<<2);
Delay by 10000
GPIOE->BSRR |= (1<<5);


The delay is just a simple counter function. So in summary, I am configuring the HSI to be a source for PLL and then setting the division and multiplication factors such that the output frequency to APB/AHB is 72MHz. SPI1 is on APB2 so after dividing 72MHz by a prescaler of 2, I get 36 MHz as the clock frequency for SPI1 since I have read that SPI1 should be around 36 MHz. I have been through the code and registers again but I cannot find my error. Thank you for your help.

0