2020-01-12 05:18 AM
I used the Cube's inits, and there seems to be no special code
But I do not get any SPI response. Always 0xff for the whole buffer
It seems the clock is not working.
Can anyone help ?
Thanks
Eli
2020-01-12 08:50 AM
Make sure the GPIO are clock enabled and alternate functions are SPI.
I guess you want master SPI mode. Use SW NSS.
Program the SPI to be master with few MHz output clock speed for bringup.
Do use the bidirectional mode (MOSI MISO SCK NSS) standard mode.
If all is programmed well, you can even stop the code while running in debug mode and play with SPI DR register to push data out manually for checking...
2020-01-13 09:53 PM
Hi and thanks for you reply.
I do not understand what you mean by " Make sure the GPIO are clock enabled and alternate functions are SPI."
I define 4 pins for the 4 SPI signals.
How do I enable clock in GPIOs?
And what is "and alternate functions are SPI."?
Thanks
Eli
2020-01-13 11:32 PM
The respective SPI pins have to be set properly in GPIO, for that, the clock for the respective GPIO has to be enabled in RCC.
Pins have to be set as AF in GPIOx_MODER, and then the appropriate AF (according to Alternate functions table in Datasheet) has to be set in GPIOx_AFR.
Then of course, SPI clock has to be enabled too in RCC, and SPI registers have to be set properly.
Cube might "have done" some of these steps for you. I don't use Cube.
Even if using Cube, it may still be a good idea to read out and check the relevant GPIO and SPI registers.
JW
2020-01-14 09:48 PM
Thanks
Will try
Eli