-
Notifications
You must be signed in to change notification settings - Fork 13.3k
SPI LIbrary Does Not Honor Clock Polarity Setting #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is mentioned in reference: On Fri, Oct 9, 2015, 17:45 Brent W. York [email protected] wrote:
|
Thanks! Although that document says modes 2 and 3 aren't supported, while I think it's the other way round. I had to set an external commercial module to accept mode 2 for it to work with the ESP8266. |
After my too-brief research, I'm suspecting that playing around with values for SPI_CLKCNT_H and SPI_CLKCNT_L might be a way to flip the clock polarity; unfortunately I don't have the toolchain installed right now to test and contribute. And hey -- thanks for making this code available, it has saved me a ton of time!!! |
If you got ESP8266 Arduino core installed, then you do have a toolchain installed. You can experiment with those settings by adding necessary .h/.cpp files to the sketch. |
I have done research on implementing this, and I am not sure if the esp8266 hardware supports it. at-least it doesn't show in the research I did. |
Fixed in #1781 |
I've tested just now with my logic analyzer. Unfortunately, it does not work. @Duality4Y where did you find the info about bit 29 in SPI1P is setting CPOL? |
Also, contrary to the initial report from @YorkBW, actually only modes 0 and 1 are supported, as the clock always idles at low. Modes 2 & 3 would require the clock idling in high state, which does not work. See here: https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase |
OK, I'm wrong. The CPOL Setting works, but the problem might be something different: Obviously, when I initialize with SPI_MODE0, the mode can not be changed later. |
@0xPIT I think you didn't meen to mention me? |
@0xPIT Here are the only references I found: Also linking #1751 here. |
BTW, as it is pointed out in the source linked above, CPHA needs to be inverted when CPOL == 1. I think this needs to be fixed in our code as well. |
Essentially, SPI modes 0 and 1 are unsupported; if these modes are requested, you actually get modes 2 and 3 respectively. It's noted in the source that setting the hardware SPI clock polarity is "TBD," but I don't think that's documented anywhere outside the source.
The text was updated successfully, but these errors were encountered: