Altera_Forum
Honored Contributor
7 years agoSPI slave clock crossing domain?
I have a question about synchronization between clock domains in SPI slave.
I need to design a SPI slave module, which has SS (slave select), SCK (SPI clock), SDI (data in from master), SDO (Data out from SPI slave). Also, in SPI slave module, it has a system clock name CLK. In SPI slave module, it has two clock domains: SCK and CLK. Those clocks are asynchronous, and frequency of CLK is much faster than frequency of SCK (frequency of CLK is 200Mhz, frequency of SCK is maximum 20MHz). I am intending to use 2 D-FlipFlops to synchronize SS, SCK, SDI from SPI clock domain to system clock domain, and all processing of SPI logic is handled in system clock domain (edge detection, FSM,... will be done at system clock domain). Could anyone answer me the following question? 1. Is it OK if I use 2 D-FFs for synchronizing SS, SCK, SDI separately (2 D-FFs for SS, 2 D-FFs for SCK, 2 D-FFs for SDI)? 2. After synchronization, at system clock domain, is there any possibility that SS, SCK and SDI signal do not have the same format as original SPI transaction? For example At SPI clock domain: Original SPI transaction: SS (High) -> SS (Low) -> SCK and SDI are input (L-> H -> L -> ...) At system clock domain: after synchronization: SS (High) -> SCK and SDI are input (L-> H -> L -> ...) -> SS (Low) I ask question 2 because I use 2 D-FFs for synchronizing SS, SCK, SDI separately. During synchronization, SS meets a meta-stability problem, so SS comes lately compare to SCK and SDI. It means that at system clock domain, the SPI transaction is not same as SPI clock domain. I am a newbie of SPI design. So my question may be amateur. But I think it is a basic question for SPI slave design.