SPI clock polarity in the STM32H7 Cube library, HAL vs LL [SOLVED]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-26 10:07 AM
Dear experts,
I'm having a weird issue with SPI initialization on STM32H743/753 .
The device connected to the SPI master needs HIGH clock polarity (CPOL). So we clicked this in CubeMX, and the generated code indeed has "hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH" and it works.
Then we switched to LL for the SPI. The LL variant is obviosly
" SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_HIGH;"
But now it fails, and works if we change it to LL_SPI_POLARITY_LOW!
Has anybody seen this behavior? H7 HAL library v 1.9.0
Solved! Go to Solution.
- Labels:
-
SPI
-
STM32Cube MCU Packages
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-04 6:03 AM
Figured it out (I guess). POLARITY_HIGH with PHASE_2EDGE behaves with my device close enough to POLARITY_LOW with PHASE_1EDGE.
The other guy who does LL changed also 2EDGE to 1EDGE.
So there's no bug in the ST library ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-26 3:02 PM
"works" doesn't imply correct. Look at the signal on the line to see what it's doing, or examine the registers.
Could be an issue where the SPI isn't initialized before you drop CS and causes an extra clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-04 6:03 AM
Figured it out (I guess). POLARITY_HIGH with PHASE_2EDGE behaves with my device close enough to POLARITY_LOW with PHASE_1EDGE.
The other guy who does LL changed also 2EDGE to 1EDGE.
So there's no bug in the ST library ;)
