2022-12-12 02:40 PM
I'd like to setup SPI mode 2 in my project with cpol=1 and cpha=0. But in SPI setup for cpha options are 1 or 2 edges. Which option do I have to select?
2022-12-12 10:38 PM
> But in SPI setup for cpha options are 1 or 2 edges.
No there isn't. SPI in STM32 is set up using the usual CPOL and CPHA settings. It's just the Cube/HAL lingo, and it's not 1 or 2 edges, it's supposed to denote first/second edge, but I don't know which one is which in terms of CPOL/CPHA. Cube is open source so you can easily look it up comparing to RM yourself if you insist on using it.
JW
2022-12-13 12:44 AM
As @Community member said, "1 edge" reffers to 1st edge
2022-12-13 02:49 AM
Still, what's "1st edge", exactly?
The traditional - and unambiguous - way to describe CPHA selection is "sample, then shift" vs. "shift, then sample".
CubeMX might've also made use of the fact that it's a visual tool, and might've added waveforms to clarify things.
JW
2022-12-13 12:21 PM
Anywhere else CPHA is setup as 0/1 or high/low. Maybe 0 is 1st edge, and 1 is 2nd edge.
2022-12-13 01:02 PM
sample on 1st clock edge vs. on 2nd edge of clock.
Quite uncommon, but not wrong. And well explained in the IDE:
hth
KnarfB
2022-12-14 12:24 AM
I learnt SPI modes with thesame 1st edge and 2nd edge sintaxis.