« Return to Thread: I2c and Avalon Bus

I2c and Avalon Bus

by K@nt () :: Rate this Message:

Reply to Author | View in Thread

Hello all,

I'm currently working on opencores I2C master (VHDL version) to
the NIOS 2 processor via the Avalon bus.(Stratix II)
There is an older post about this subject but I can't resolved my problem.

So I've used i2c_master_top_avalon.vhd and I've created a wrapper to use this component with Avalon bus oc_i2c_master.vhd 

I've configured the component
 

and attached this to a NIOS 2 processor


I've assigned Sda ans Scl


So I use I2c to configure a video camera (http://ltc.cit.cornell.edu/courses/ee476/FinalProjects/s2006/jzs3_da65/jzs3_da65/C3088.pdf ) but  i can't set this !!

I think the problem is it can't recognize the slave (video camera), in fact when I write a value into the register of the video camera I'm waiting for the TIP flag and RxACK flag but the RXACK always stay at '1'...

At start I've thought there was a problem with the slave adress but i've tested all the values between 0 and 255 with no success !!!

An exemple of my code to write into slave's register :

// address : address of the slave
// reg : address of the slave's register
// data : value  wich write in the slave's register

void i2c_write(unsigned char address, unsigned char reg, unsigned char data) {
 
// write address
  IOWR_I2C_TXR(address);
  IOWR_I2C_CR(OC_I2C_STA | OC_I2C_WR | OC_I2C_ACK );
  i2c_wait_tip();
  i2c_rxack();
 
  // write register address
  IOWR_I2C_TXR(reg);
  IOWR_I2C_CR(OC_I2C_STA | OC_I2C_WR | OC_I2C_ACK);
  i2c_wait_tip();
  i2c_rxack();

  // write data
  IOWR_I2C_TXR(data);
  IOWR_I2C_CR(OC_I2C_WR | OC_I2C_STO);
  i2c_wait_tip();
  i2c_rxack();
}

void i2c_rxack(void){
 while ((IORD_I2C_SR & OC_I2C_RXACK)> 0 ) {}
 }

I've initialized CTR (0x80) before write into slave's register

Can I have some help, please ?

Thank you very much

Regards

 « Return to Thread: I2c and Avalon Bus