-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph/spi: Switching between CPOL=0,1 problems on Kinetis with software CS #6567
Comments
Also, the LIS3DH driver works if we retry the who am I query during init, but that's just hiding the problem because the first transfer will have placed the bus in the correct clock polarity for the second transfer. |
Will look into this as soon as I can. |
@haukepetersen did you? |
@MrKevinWeiss I just wanted you to be aware of this issue. |
Thanks, I have kinetis boards and a scope. I will check it out! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
ping @MrKevinWeiss |
Darn, I will try to remember when I'm back from vacation. |
@MrKevinWeiss obviously you didn't |
True... I'll check it out, thanks! |
@MrKevinWeiss many thanks! What is your interpretation of the results? On first sight CS behavior looks normal to me, although it returns to high very fast in some configurations. Furthermore, the logic analyzer didn't decode all cases correctly. Did you just miss to switch the decoder mode? |
I think there could be the problem when using soft CS and low power mode that @MichelRottleuthner pointed out on another platform (clock ends in the wrong polarity). My interpretation is: Which matches, the decoding was probably just a setting on the scope. My intention wasn't to show the decoding but the signals. Mode 0 and mode 3 both trigger the first rising edge, the only difference is the initial clock level, mode 3 starts high and mode 0 starts low. I may have missed the initial capture of some of these actually and remember some problems that resulted in sending the command twice. This may be because in mode 3, the clock pin starts low and when the CS pin goes low the device sees a clock pulse as the clock tries to go to its desired starting position. We don't see this the second time around because the SW CS leaves the clock high. I would suggest setting the SCK based on the polarity setting during init. |
So... is this a bug? Can it be fixed? Did we fix it? |
(I did not yet verify this with a scope)
The software CS is causing problems when moving between different clock polarity settings.
We discovered that the LIS3DH driver on mulle requires setting the SPI mode to 0, but it should be using mode 3 according to the data sheet, as well as when using the old SPI driver and when using a different driver in Contiki. Clearly there is something different with the new RIOT SPI driver.
The current driver also works in mode 3 if the LIS3DH configuration is changed to use hardware CS on Mulle (PR #6572).
I believe that the problem arises from the fact that the CS pin is asserted before the new clock polarity setting is applied to the SPI module, resulting in the device picking up the clock polarity change as a normal clock pulse, when in fact it should be ignored. However, this does not explain why it used to work in the old periph driver, which also was using software CS where the CS pin was managed by the LIS3DH driver itself instead of deferred to the SPI bus driver.
This needs investigation with a scope or logic analyzer.
The text was updated successfully, but these errors were encountered: