Author Topic: How to create SPI slave in FPGA when SCLK frequency similar to FPGA system clock  (Read 7340 times)

0 Members and 1 Guest are viewing this topic.

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9180
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
If the SPI clock isn't continuous (that is is stops between transfers), you cannot really use it as an FPGA clock because all the logic clocked by this clock will stop along with the clock. In this case, create an internal clock which is at least 4-5 times faster than SPI and sample the SPI clock and data as needed.
Or add dummy bytes to let the FPGA finish the SPI operation.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline matrixofdynamismTopic starter

  • Regular Contributor
  • *
  • Posts: 200
The FPGA gets data from an ADC. It will eventually have to pass this into the uC via SPI. Thus, although the primary purpose of the SPI is to make it possible to read write certain control registers inside the FPGA, the design will have to be extended to also transfer several thousand bytes of data from FPGA to the uC.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27614
  • Country: nl
    • NCT Developments
You can easely solve that by having one of the SPI readable registers connected to a FIFO (which is fed by ADC data). If the register width is wider than the FIFO you can add status bits to the FIFO read registers telling the reading is valid or not. From there you can add some extra logic to create an interrupt or 'data ready' status (which becomes active when the FIFO is half full or 3/4 full for example) pin connected to an IO pin of the microcontroller. Depending on the datarate you can either simply poll for data or use the interrupt / 'data ready' to read bursts of data from the FIFO once this is available.
« Last Edit: March 22, 2021, 05:08:55 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2772
  • Country: ca
Dummy cycles between receiving address and sending out data are often used by high-speed flash memory chips.

Offline matrixofdynamismTopic starter

  • Regular Contributor
  • *
  • Posts: 200
I will use dummy cycles. The ADC uses source synchronous interface at 120MHz. I will use 60MHz clock to read the DCFIFO and read two bytes at a time instead. This is how I end up with 60MHz system clock for the FPGA design. It is good idea to keep clock domains to minimum really.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf