mattvenn / basic-ecp5-pcb

Reference design for Lattice ECP5 FPGA. Featuring Raspberry Pi interface and 6 PMODs
Creative Commons Zero v1.0 Universal
98 stars 23 forks source link

spi clock input pin #3

Open mattvenn opened 4 years ago

mattvenn commented 4 years ago

The ecp5 spi clock pin is used for configuration (reading SPI flash or being an SPI peripheral) and is detailed in TN1260 pdf. The SPI clock pin is on ball N9, but this can't be used in the constraints file.

After configuration it can work as an output using the USRMCLK primitive:

wire tristate = 1'b0;
USRMCLK u1 (.USRMCLKI(spi_clk), .USRMCLKTS(tristate));

It seems it can't be used as an input. It might work with the FPGA setup as SPI peripheral: sysconfig = 001.

The board sets sysconfig to 010 as SPI controller. This is done with RN1.

workaround is to use the shared connection between raspberry pi gpio6 (pin 31) and fpga ball t6. Bridge pi gpio6 to spiclk (gpio11). Make sure that gpio6 is set to an input on the pi:

gpio -g mode 6 in

mattvenn commented 4 years ago

see test-spi-clk-in branch for an example.

mattvenn commented 4 years ago

tying raspi pins together with a direct short doesn't seem to work. but soldering a header on, and using a jumper does. This was tested on 2 boards. so before fixing this on the board need to understand what is happening.

francis2tm commented 2 years ago

Hello, nice work with this repo. I think I didn't quite understand your comments. If the ECP5 is configured in Slave SPI mode (thus, the configuration SPI clock pin should be an input) it is not possible to reuse all the SPI pins after the ECP5 is configured, that is, in user mode? I'm designing a board where the ECP5 is connected to a microcontroller via SPI and the microcontroller is the master. The objective is to use the same SPI bus to:

  1. Microcontroller configures ECP5, ECP5 in Slave SPI mode
  2. Data transfers ECP5 <-> Microcontroller when ECP5 is in user mode.

From your experience, is it possible?

mattvenn commented 2 years ago

I'm sorry I can't remember. Reading my comment I think the limitation is the pin can't be used as an input. I would advise you to test before doing a board layout.

francis2tm commented 2 years ago

thanks for the reply