Random Address Read eeprom M24256

Hi,

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 ?

Br,

Parents Reply Children
  • Hi,

    what is the correct baudrate that I need to use with M24256 chip.
    It seems slow the wrinting and the reading.

    Now I have 

    /* Set bit rate */

    SCI1.BRR = 0x19U;

    I modified the code inserting  this flag flag_e2read_pippuz and I set it to 1 when I need to write and put it to 0 when I need to read. The other part of the code is the code generated from Smart Configuration.

    The system seems slow.

    Please let me know if I am wrong or not.

     

    void r_Config_SCI1_receive_interrupt(void)

    {

    volatile uint8_t dummy;

    if (0U == SCI1.SISR.BIT.IICACKR)

    {

    if (_80_SCI_IIC_TRANSMISSION == g_sci1_iic_transmit_receive_flag)

    {

    if (g_sci1_tx_count > 0U)

    {

    SCI1.TDR = *gp_sci1_tx_address;

    gp_sci1_tx_address++;

    g_sci1_tx_count--;

    }

    else

    {

    if(flag_e2read_pippuz == 1)

    {

    /* Generate stop condition */

    g_sci1_iic_cycle_flag = _00_SCI_IIC_STOP_CYCLE;

    R_Config_SCI1_IIC_StopCondition();

    }

    }

    }

    else if (_00_SCI_IIC_RECEPTION == g_sci1_iic_transmit_receive_flag)

    {

    if (0U == SCI1.SIMR2.BIT.IICACKT)

    {

    if (g_sci1_rx_length > g_sci1_rx_count)

    {

    *gp_sci1_rx_address = SCI1.RDR;

    gp_sci1_rx_address++;

    g_sci1_rx_count++;

    }

    }

    else

    {

    dummy = SCI1.RDR;

    }

    if (0U == g_sci1_rx_count)

    {

    if(1U == g_sci1_rx_length)

    {

    SCI1.SIMR2.BIT.IICACKT = 1U;

    }

    else

    {

    SCI1.SIMR2.BIT.IICACKT = 0U;

    SCI1.SCR.BIT.RIE = 1U;

    }

    }

    else if (g_sci1_rx_length == (g_sci1_rx_count + 1))

    {

    SCI1.SIMR2.BIT.IICACKT = 1U;

    }

    else

    {

    /* Do nothing */

    }

    /* Write dummy */

    SCI1.TDR = 0xFFU;

    }

    else

    {

    /* Do nothing */

    }

    }

    else

    {

    /* Generate stop condition */

    g_sci1_iic_cycle_flag = _00_SCI_IIC_STOP_CYCLE;

    R_Config_SCI1_IIC_StopCondition();

    }

    }

    Br,

  • Hi, I recommend using 100Kbps, although it supports 400Kbps and 1Mbps. 
    Regarding your code, I found out the SCI unit isn't compatible with your needs, but you can configure the RIIC0 instead of SCI, as it inherently supports restart conditions and has the no_stop send APIs. 

    Thanks for your patience, I'm working on it, and I share that as soon as possible.