I2C send memory address in read operation

Hello,

I'm trying to implement a comunication with a I2C device. I have a RA6M4 microcontroller and just one slave device on I2C.

The write operation seems to be good, as far the device has a expected behaviour.

But, in read operation, i can not fulfill the sequence of the device. The sequence is like a I2C read memory:

The point is:

- If I execute the read function (R_IIC_MASTER_Read), the start, device address, read bit, and acknoledge is good, but register address is always 0xFF, like a dummy byte.

- If I execute the write function, (R_IIC_MASTER_Write), the start and device address is good, but it sends always the write bit (0).

So, how can I achieve the correct sequence? No examples found that work it.

Thanks.

Parents
  • HI David, on closer evaluation I don't think that diagram is possible.  There must be a re-address with LSB set for read for the device to go into read mode.  A slave device cannot accept data, and then send data, without being re-addressed. Can you share the manual where you got that diagram?  Did you read IK_Renesas response?

  • Hello,

    first, thanks all for helping me in this issue.

    The datasheet of my led drive is this: KTD2026-7-04h.pdf

    At this device, I can do writes, so at this moment I can put a led ON and OFF.

    Just to be sure, i copy again the entire function readreg of example provided here, and check the values of TRANSFER_SIZE, RECEIVE_SIZE and TRANSMIT_SIZE.

    The led driver has 8 bit registers, so i'm reading the values inside the function readreg (output[]) just before is copy to the value parameter, just to be sure i'm not leaving some info readed, because this function will read 2 bytes.

    To change the led ON and OFF, i'm writing to register 4, so i'm very sure of the contents of this registers: 1 when is ON, 0 when is OFF.

    After put the led ON and OFF, I call to readReg(4, data16); and i'm always getting the same values at the end of readreg function:

    Makjing some tests, If I change RECEIVE_SIZE  to 1, i get an I2C_MASTER_EVENT_ABORTED. So it remains at value 2.

    At this point, I'm pretty sure that is impossible to read this device, at least with fsp driver.

    Another thing that is boiling my head is that, when I started at programing microcontrollers (I think more than 20 years ago) I remember that reading an I2C device is a sequence like my led driver is saying. But i can not remember what devices i was working on, so I can not check that.

    After all, just for this led driver, I can skip read its registers, but will be a mark in my memories that this has no solution.

    As AZ_Renesas said, "The read operation on your datasheet cannot be implemented with RA".

    If you have some others ideas, tell me and I can check it.

    Thanks.

  • Hello David,

    The standard method to read a slave device on I2C protocol is what suggested from IK_Renesas.

    You shared with us your code for writing on the slave device, could you please share with us  your code that you implemented, in order to read  from your slave device?

    If you could attach your whole project with FSP configuration, it would be appreciated.

    Regards,

    AL_Renesas

Reply
  • Hello David,

    The standard method to read a slave device on I2C protocol is what suggested from IK_Renesas.

    You shared with us your code for writing on the slave device, could you please share with us  your code that you implemented, in order to read  from your slave device?

    If you could attach your whole project with FSP configuration, it would be appreciated.

    Regards,

    AL_Renesas

Children