Forum Discussion

jpark198's avatar
jpark198
Icon for New Contributor rankNew Contributor
6 years ago
Solved

Why I2C Master core not work?(MAX10)

I use DE10-LITE board.

I try to use I2C for connect with external ROM.

In QSYS, I set up NIOS and I2C Master Core.

it is my code

GPIO(0) <= '0' WHEN SDA_OE = '1' ELSE 'Z';

GPIO(1) <= '0' WHEN SCL_OE = '1' ELSE 'Z';

SDA <= GPIO(0);

SCL <= GPIO(1);

u0 : component QSYS

port map (

clk_clk => MAX10_CLK1_50, -- clk.clk

reset_reset_n => RST, -- reset.reset_n

i2c_0_i2c_serial_sda_in => SDA, -- i2c_0_i2c_serial.sda_in

i2c_0_i2c_serial_scl_in => SCL, -- .scl_in

i2c_0_i2c_serial_sda_oe => SDA_OE, -- .sda_oe

i2c_0_i2c_serial_scl_oe => SCL_OE -- .scl_oe

);

and i write program code in Eclips like this.

i2c_dev = alt_avalon_i2c_open("/dev/i2c_0");

if (NULL==i2c_dev)

{

printf("Error: Cannot find /dev/i2c_0\n");

//return 1;

}

while(1)

{

alt_avalon_i2c_master_target_set(i2c_dev,SLAVE_ROM_ADDR);

status=alt_avalon_i2c_enable(i2c_dev);

i2c_tx_buf[0] = 0x00;

i2c_tx_buf[1] = 0x00;

i2c_tx_buf[2] = 0x03;

i2c_tx_buf[3] = 0x04;

status=alt_avalon_i2c_master_tx(i2c_dev, i2c_tx_buf, 4, 0);

}

and i connect gpio pins to oscilloscope. but it doesn't send any signals.

what is problem?