Now this board is available at tindie store!
Lattice MachO2 has a wonderful embedded block enables handy I2C device creation. Here I would like to show you how to enable it. Starting from scratch is far beyond my level and let's start from Lattice's reference design.
(1) Get files from Lattice site
By googling "RD1124 Lattice" will guide you the download site. Just click zip file and download it.
(2) Extract zip and place it on your folder
Inside zip file, it contains "rd1124" and let's put it in, for example document folder
(3) Open project file
Inside rd1124 folder, it contains files both for MachXO3 and MachXO2. Let's confirm the file inside project/xo2/verilog. Now execute Lattice Diamond and select the project file...
(4) Change program device
The default device is 132pins version but my board is TQFP100 version of LCMXO2-1200HC. Let's change the device by right click on the device name.
The appropriate selection is shown above. Please don't forget to change package type to TQFP100.
(5) Source file modification
The original sample file assume 132pins version and it cannot be fit inside TQFP100 version (lack pins). Let's change values of i2c_gpio.v as above and save file...
(6) Rerun synthesize by modified verilog file
On the process tab, right click on "Lattice Synthesis Engine" will create new file along the modification. Just parameter change will not make any error...
(7) Pin layout definition
Currently pin layout is not still defined. Click "Spreadsheet View" will show you the layout window..
First of all, let's change logic level from 2.5V to 3.3V. Multiple selection by shift-click and right click and select "LVCMOS33" will change all of pin logic at once.
Now input pins can be written as above (along my board connection). Clock is injected to pin 63 in my board but we need to adjust it design by design. Five GPIO input are connected to tactile switch in my board. Just to be noted is pull mode of RST_N. It should be "UP", otherwise it will remain reset.
And let's define output pins. In my board, Pins of GPIO_0 (1, 2, 4, 7, 8, 13, 16, 17) are connected to LED bus and 21, 24, 25 are device selection (active low). It will not hurt but let's set them all "NONE" for pull mode.
(8) Device programming setting
Let's check "JEDEC file" in Export File and right click to "Rerun". This will not show any error if pinout can be fit inside FPGA.
Now let's connect board to computer!
Now let's add "Programming File" by right click and Add->New file and
Select "Other Files" in categories and name it. The name does not matter, and click "New"
It will show you device scan selection and just click "OK"
After certain period, you will see the device scan result. It is yellow but don't need to care about it. Just confirm "File Name" column is not empty but filled as above picture.
(9) Finally Program!
Just click "Programmer" and
"Program" will make your board to be I2C controlled GPIO board!!
How to configure I2C of EFB??
The above sample is just using preconfigured I2C block in sample, but of course we can configure them by very quick way.
From Tools menu, click "IPexpress"
We can see vast number of wonderful possibility (these functions, not limited to EFB, can be tailored and utilize!) but just click "EFB" and set up Project Path by Browse button.
The default folder to be set for IPexpress is source/verilog/ipexpress/xo2. Just select Folder and
name file "efb" and Module Output as "Verilog" and click "Customize"
You will see confirmation of overwrite. Yes, it means the modification will reflect on the current project. Click "OK"
We have SPI, Timer/Counter and PLL and Flash memory in addition to I2C!!. Current interest is I2C and it has three types, Primary Configuration, Primary User, and Secondary User. MachXO2 has two I2C block and Primary user is connected to pre-defined pins (86 and 85 for SDA, SCL) but Secondary User can take arbitral pins for SDA/SCL. Let's check only "Primary user" and click...
Read more »