2025-08-16 4:19 AM
I use the KIT STM32F411 Discovery
When I choose:
SPI CPOL: Low
SPI CPHA: 1 Edge
It works
But when I choose:
SPI CPOL: High
SPI CPHA: 2 Edge
It does not work
Could you explain why? Thank you!
2025-08-16 6:20 AM
> SPI CPOL: High
> SPI CPHA: 2 Edge
These are the correct settings. If it doesn't work, there's probably a bug in your code.
Ensure SPI peripheral is active before you assert CS. Send a dummy transfer without CS active in order to ensure this.
2025-08-17 8:52 AM
2025-08-17 10:20 AM
What about your program isn't working?
What does L3GD20_Read_WHOAMI return?
> hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
> hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
These are incorrect, as explained above.
2025-08-18 2:47 AM
I recorded my screen and send you my project in the attachment.
It works when:
> hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
> hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
It does not work when:
> hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
> hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
I still don't know why : ((
Thank you very much !!!
2025-08-18 5:52 AM - edited 2025-08-18 5:52 AM
If you can't clearly explain what isn't working here, I'm afraid I won't be able to help. I'm not watching a 4.5 minute video to try and find out. You didn't answer my question about L3GD20_Read_WHOAMI.
2025-08-18 9:01 AM
Hi
What does L3GD20_Read_WHOAMI return?
--> It returns 211
When I use
> hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
> hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
The sensor returns only 1 time (then the sensor data does not change anymore)
Do you know the reason why?
Thank you
2025-08-19 7:30 AM
Try doing a dummy SPI transfer (with CS high) prior to your first SPI transaction, but after SPI is initialized.
If that doesn't work, please include the code you're using with the fixes from above.