[SOLVED] SPI STM32F407 not working

Post here first, or if you can't find a relevant section!
acronis
Posts: 147
Joined: Thu Mar 02, 2017 12:32 pm

Re: SPI STM32F407 not working

Post by acronis » Wed Nov 08, 2017 12:15 pm

Dear friends !

Thank you all for your help in my question !
A special thank you stevestrong !
YOUR code works fine !!!

All of you correctly wrote to me. (((
I was not paying attention, the problem was in the wire connecting the CS of the microcontroller and the sensor wire was bad (Chinese quality) and there was no contact.
Changed the wire and now the management of the sensor occurs, but there is no answer because of too high speed SPI.

I need to configure the STM32F407 on the frequency of 128 MHz .
Please tell me how it right to do ?
Can it be done in Setup () ?

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: SPI STM32F407 not working

Post by stevestrong » Wed Nov 08, 2017 12:35 pm

Are you really sure that 1.3125 MHz or 0.65625MHz is not good enough?

If you set the CPU to 128MHz, the USB will not work.
If you want to keep the USB serial, then 120MHz is the solution, where the SPI clock will be 0.9375MHz.
For this, you can try to use in setup:

Code: Select all

SetupClock120MHz();
from here: https://github.com/rogerclarkmelbourne/ ... cF4.c#L274

acronis
Posts: 147
Joined: Thu Mar 02, 2017 12:32 pm

Re: SPI STM32F407 not working

Post by acronis » Wed Nov 08, 2017 12:41 pm

Steven , and how to make 0.65625 MHz ?

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: SPI STM32F407 not working

Post by stevestrong » Wed Nov 08, 2017 1:04 pm

Code: Select all

  spi.beginTransaction(SPISettings(1000000));
Although the passed parameter is 1MHz, but during the internal calculations in the SPI lib, the physical clock value will be set to the equal or next lower supported frequency, which is 656.25 kHz.

To have 1.3125 MHz you can use as passed parameter value 1400000.

acronis
Posts: 147
Joined: Thu Mar 02, 2017 12:32 pm

Re: SPI STM32F407 not working

Post by acronis » Wed Nov 08, 2017 1:07 pm

Now it is clear.
And then I thought that there really is 1 000 KHz.
Thank You again !!!

Post Reply