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.
Hello David,
Thanks for reaching out Renesas Engineering Community.
First of all I would suggest to you to advise the documentation of the r_iic_master module in FSP.
https://renesas.github.io/fsp/group___i_i_c___m_a_s_t_e_r.html
There is also an example code.
Also let me inform you that the IIC driver in FSP is a non blocking driver, which means that for example if your preform a Write operation
the R_IIC_Write() API will return immediately and you should declare a callback as this one shown below to get notified that your operation is actually completed even though it returns FSP_SUCCESS.
/* Callback function */ void g_i2c_master0_callback(i2c_master_callback_args_t *p_args) { /* TODO: add your own code here */ i2c_event=p_args->event; }
And check the value of the variable i2c_event. And check if it gets one this values below:
In order to find out what is going wrong we would like to have more information from you like your configurations for I2C and some sample code.
However let me attach for you an example for I2C that worked for me for reading an I2C temperature sensor. Notice that the example might be forEK-RA2L1 but nothing changes as far as it concerns the code, only set your own slave address and of course change the configurations for EK-RA6M4 for the I2C stack (pins, channels etc.).
Hope this helps.
Best Regards,
IK
5355.i2c_masterEK_RA2L1.zip
And of course pull-up resistors are required for the slave device: