Thanks to visit codestin.com
Credit goes to github.com

Skip to content

periph/spi: Switching between CPOL=0,1 problems on Kinetis with software CS #6567

@jnohlgard

Description

@jnohlgard

(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.

Metadata

Metadata

Labels

Area: cpuArea: CPU/MCU portsArea: driversArea: Device driversPlatform: ARMPlatform: This PR/issue effects ARM-based platformsType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions