Skip to content
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

SPI core mode 0 is racy #2644

Open
bgamari opened this issue Jan 17, 2024 · 3 comments
Open

SPI core mode 0 is racy #2644

bgamari opened this issue Jan 17, 2024 · 3 comments

Comments

@bgamari
Copy link
Contributor

bgamari commented Jan 17, 2024

Currently if one configures the Clash.Cores.SPI.spiMaster in Mode 0, the end of the transfer will race between CS and the capture clock. Specifically, the produced output will raise CS at the same moment as the last falling SPI clock edge (which the subordinate will sample on).

A similar race is avoided at the beginning of the transfer by the waitTime argument, where a few core clock cycles are inserted between CS being lowered and the SPI clock starting. Perhaps a similar delay should be inserted at the end of the transfer as well?

@bgamari
Copy link
Contributor Author

bgamari commented Jan 17, 2024

Actually, I may have been a bit premature here. Closing until I have confirmed.

@bgamari bgamari closed this as completed Jan 17, 2024
@bgamari bgamari reopened this Jan 18, 2024
@bgamari
Copy link
Contributor Author

bgamari commented Jan 18, 2024

I do believe that this is indeed a problem. While there is a cycle of delay between the sampling edge and the rise of CS, this violates the timing requirements for the DAC8734 (and I suspect most other subordinates).

@DigitalBrains1
Copy link
Member

DigitalBrains1 commented Jan 18, 2024

I think we can reuse waitTime for a delay at the end as well. I haven't looked at any datasheets, but differences in propagation delays might even make a slave observe S̅S̅ deassert before they see the clock edge. Surely there needs to be an appreciable delay before S̅S̅ is deasserted at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants