Random Address Read eeprom M24256


I am trying to read and write eeprom M24256.

I have used smart configuration but I am not able to read data in random address read.

Datasheet related eeprom said:

Random Address Read:

A dummy write is performed to load the address into the address counter. Then, without sending STOP condition, the master sends another START condition, and repeats the Device Select Code, with the RW bit set to 1. The memory acknowledges this, and outputs hte contents of the adressed byte. The master must not acknowledge the byte output, and terminates the transfer with stop condition.

Could you indicate to me how can manage this situation ?


  • Hi,
    I can configure in this way.



    So I don't know if I can use your code.

    Let me know if I can use your suggestion.

    I think that in the code while I need to use == 1 and not == 0

    while(IIC_transmission_end == 0);//Wait for the data to be sent


  • To use the RIIC0 or RIIC2 unit follow the below steps that are for RX64M series:

    According to that, you can use SCL0/SDA0 or SCL2/SDA2 related pins on your hardware. the GPIO configuration will be set automatically by the smart configurator based on components that you're using. 

    And about the "IIC_transmission_end" it's nothing more than a variable that I've used to indicate the end of transmission both in I2C send and received end interrupts. Please don't change it for now. 

  • Hi,

    I have configured all following your suggestion, I changed 

    /* Set SCL0 pin */

    MPC.P30PFS.BYTE = 0x0FU;

    PORT3.PMR.BYTE |= 0x01U;

    /* Set SDA0 pin */

    MPC.P26PFS.BYTE = 0x0FU;

    PORT2.PMR.BYTE |= 0x40U;

    because I have different port in my RX64M,

    but it doesn't work.

    In my view when I need to write I must use at least 0xA0

    like Device Select and when I read I must use 0xA1.

    Using your code I obtain watchdog restart the micro

  • Dear Lucaodex, are you sure you have I2C signals on your device? It would be great if you could monitor SCL/SDA lines with a logic analyzer or oscilloscope to ensure the device is responding to the IIC interface. 
    Regarding watchdog restart, yes it's because of while(1) loops that I've used for making delay between transmissions and when the device isn't responding CPU hangs there. (So feel free to create a fresh project and don't use Watchdog for testing)

     Regards "0xA0 and 0xA1" device addresses, the R_Config_RIIC0_Master_Send() function works with 7bit addresses, and it automatically changes the LSB based on the Read or Write request. 

    I'm suspicious about your configuration and setup. and make sure you've putten this line " R_Config_RIIC0_Start();//RIIC0 Initialization"  before using other functions. 

  • Hi,

    I have this schema

    I don't use while loop but only one shot operation, so one write and one read

    I have inserted  Start at the begging of main and I checked the Create in R_Systeminit

    void main(void)




    R_Config_RIIC0_Start();//RIIC0 Initialization



    I have some doubt about SCL0 and SDA0 configuration, really I don't know it right.

    /* Set SCL0 pin */

    MPC.P30PFS.BYTE = 0x0FU;

    PORT3.PMR.BYTE |= 0x01U;

    /* Set SDA0 pin */

    MPC.P26PFS.BYTE = 0x0FU;

    PORT2.PMR.BYTE |= 0x40U;

    Unfortunately, it's not possible to use RIIC0 or RIIC2 on your hardware. and it's not predicted by the PCB designer. 

    If you're obligated to use that hardware you need to have a little surgery on your board, to connect either P16/P17 or P12/P13 to your memory I2C bus. or implement the code on SCI. 
    However, I recommend you give the RIIC0 code a try and do the surgery on the board, as it's much more convenient to work with. 

  • Hi,

    I'm sorry about it, do you have any suggestion on how to use SCI1 ?

    I have some problem to comunicare with eeprom.


  • Unfortunately, I've some doubts about making a  Restart Condition using the SCI unit.

    As I mentioned earlier, the M24256 that you're using needs two consecutive START conditions to respond to Random address data read. which is known as the Restart condition and can be done with the RIIC unit. 
    But the way the SCI unit behaves is different as it's versatile and supports different types of communications 
    the start and stop conditions should come after each other and we cannot manually adjust it and make a Restart condition (I tried but I couldn't do that even using registers).

    Although we might find a hack to do so, for now, unfortunately, I can't help with it. 

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator