Forum Discussion
Hi all,
This is what the data sheet (Reference Manual) shows on I2C:
And this is the output of the IP platform:
I find the names a bit confusing to be honest, I think an example would help. I'm still working on this. The datasheet also says:
So I'm guessing this is the actual I2c clock? There are four signals in total exported from Platform Designer, I suppose they are the four signals that are mentioned in the datasheet?
This is what I have for now, I will let you all know how it goes.
Cheers,
Alberto
- Alberto_F3 years ago
New Contributor
Ok, I got it running, here it is for future references and as an example to anyone who needs this:
The above are the four I2C signals used to interface to the FPGA and the output, NOT the 50MHz clock. The project generates the following interface:
-- I2C2 (FPGA) hps_0_i2c2_clk_clk : out std_logic; -- I2C SCL Control Signal hps_0_i2c2_out_data : out std_logic; -- I2C SDA Control Signal hps_0_i2c2_sda : in std_logic; -- SDA Input pin hps_0_i2c2_scl_in_clk : in std_logic; -- SCL Input pinThe first two signals above are the control for the BUFIO that drives the output, while the signals below are the input signals from the pins. To correctly drive the output and read the signals in, I added the following process:
i2c2_proc: process(hps_0_i2c2_clk_clk, hps_0_i2c2_out_data) begin if(hps_0_i2c2_clk_clk = '1') then I2C2_SCL <= '0'; else I2C2_SCL <= 'Z'; end if; if(hps_0_i2c2_out_data = '1') then I2C2_SDA <= '0'; else I2C2_SDA <= 'Z'; end if; end process; hps_0_i2c2_scl_in_clk <= I2C2_SCL; hps_0_i2c2_sda <= I2C2_SDA;The above is the equivalent of the image below, although the naming is confusing.
Once the project is generated, you MUST re-generate the QTS files, which will effectively set this line "1, /* I2C2USEFPGA */" in pinmux_config.h.
Also, to make sure your bootloader and Linux system recognise the new module, you need to explicitly add them to the drivers:
/* UBOOT */ &i2c2 { status = "okay"; clock-frequency = <100000>; compatible = "snps,designware-i2c-17.0", "snps,designware-i2c"; clocks = <&l4_sp_clk>; status = "okay"; /* embeddedsw.dts.params.status type STRING */ clock-frequency = <100000>; i2c-sda-hold-time-ns = <100>; i2c-sda-falling-time-ns = <100>; i2c-scl-falling-time-ns = <300>; };/* Linux */ &i2c2 { status = "okay"; clock-frequency = <100000>; };Recompile and test. Remember to add pullup resistors on the SDA and SCL lines.
Hope this helps.
Cheers,
Alberto