Skip to main content
jonathannakache9
Associate
July 6, 2012
Question

Conflict with two EEPROM

  • July 6, 2012
  • 27 replies
  • 3837 views
Posted on July 06, 2012 at 10:02

Hi,

With a STM32, I have a problem

to select

either

EEPROM

(

M24LR64-R and M24M02-DR)

on the same bus

I2C

.

Here are the

''device

select

code

'':

For

M24LR64

-R:  1 0 1 0     X 1  1 X

In the order

:  1 0 1 0 = Device type identifier   X = E2   1 1 = E1 E0 ( chip enable)   X = RW

For

M24M02

-DR:

1 0 1

0   1

X

X

X

In the order

: 1 0 1 0 = Device type identifier   1 = E2 ( chip enable)   X X = A17 A16 (MSB address bits )    X = RW

The two

address bits

A17

and

A16

for

M24M02

-DR

can not be

used

because they would

pose

a conflict with the

R

-

M24LR64

there is

there a way

around the problem

?

Thank you for your

response

,

#pounds-head-on-desk
    This topic has been closed for replies.

    27 replies

    emalund
    Associate III
    July 11, 2012
    Posted on July 11, 2012 at 16:57

    this has been confusing because sometimes the reference is to the

    M24LR64-R and sometimes to the M24M02-DR

    anyhow I am sure you need to have A16and A17 the same when writing the address and switching to read, do you?

    Erik
    Tesla DeLorean
    Guru
    July 11, 2012
    Posted on July 11, 2012 at 16:57

    but A17 bit and A16 bit are selected in the device_selected so you have 4 devices on the bus? if not the above makes no sense

    The single device contains 4 arrays of 64KB (ie 256KB or 2Mbit), which array is expressed in the address of the I2C device, not the offset expressed in the following two bytes.

    It's hanging presumably because the I2C device isn't ACKing because it doesn't recognize the address presented on the bus.

    Presenting some code might be instructive to see if there is an issue there.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    jonathannakache9
    Associate
    July 11, 2012
    Posted on July 11, 2012 at 17:22

    yes, it's the problem.. no ACK

    the code:

    void
    config_i2c()
    {
    unsigned 
    char
    chip_select = 0xAC; 
    // 1010 1100
    int
    i = 0;
    char
    tx1_buffer[] =
    ''test''
    ;
    char
    rx1_buffer[100];
    bzero(rx1_buffer,100);
    I2C_InitTypeDef I2C_InitStructure;
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_OwnAddress1 = chip_select;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = 100000;
    I2C_Cmd(I2C1, ENABLE);
    I2C_DeInit(I2C1);
    printf
    (
    ''strlen(tx1_buffer) = %d
    
    ''
    , 
    strlen
    (tx1_buffer));
    I2C_Init(I2C1, &I2C_InitStructure);
    while
    (I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY));
    I2C_ITConfig(I2C1, I2C_IT_EVT | I2C_IT_BUF , ENABLE);
    write_EEPROM(0x0, chip_select, tx1_buffer, 
    strlen
    (tx1_buffer));
    Delay_ms(5);
    read_EEPROM(0x0, chip_select + 1, rx1_buffer, 
    strlen
    (tx1_buffer));
    printf
    (
    ''donnees recues de l'eeprom: %s
    
    ''
    , rx1_buffer);
    }

    void
    write_EEPROM(uint16_t ReadAddr, unsigned 
    char
    chip_select, 
    char
    *ptx1_buffer, 
    int
    len_tx1_buffer)
    {
    int
    i = 0;
    I2C_GenerateSTART(I2C1, ENABLE);
    while
    (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
    /*!< Send EEPROM address for write */
    I2C_Send7bitAddress(I2C1, chip_select , I2C_Direction_Transmitter);
    while
    (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
    I2C_SendData(I2C1, (uint8_t)((ReadAddr & 0xFF00) >> 8));
    while
    (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
    I2C_SendData(I2C1, (uint8_t)(ReadAddr & 0x00FF));
    while
    (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
    for
    (i = 0 ; i < len_tx1_buffer ; i++)
    {
    I2C_SendData(I2C1,*ptx1_buffer);
    ptx1_buffer ++;
    while
    (!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
    }
    I2C_GenerateSTOP(I2C1, ENABLE);
    while
    (I2C1->CR1 & I2C_CR1_STOP);
    }

    emalund
    Associate III
    July 11, 2012
    Posted on July 11, 2012 at 18:55

    anyhow I am sure you need to have A16and A17 the same when writing the address and switching to read, do you?

     

     

    you do not show your read routine where the above is essential when you turn the bus.  Please post it

    Erik

    jonathannakache9
    Associate
    July 12, 2012
    Posted on July 12, 2012 at 09:07

    because that is

    when I

    send

    I2C_Send7bitAddress(I2C1, chip_select , I2C_Direction_Transmitter);

    I have not received the ACK from the device

    emalund
    Associate III
    July 12, 2012
    Posted on July 12, 2012 at 19:23

    Is the E2 pin on the chip tied to Vcc?

    is the !WC pin on the chip tied to ground?

    Erik

    jonathannakache9
    Associate
    July 16, 2012
    Posted on July 16, 2012 at 09:40

    yes...