Skip to main content
Visitor II
June 22, 2020
Solved

M95512-D EEPROM with STM32F103RCT7 Communication is not working.

  • June 22, 2020
  • 3 replies
  • 3266 views

0693W000001rfUMQAY.pngHi,

Im using M95512-D EEPROM with STM32F103RCT7. EEPROM is connected with SPI2. 

My Initialization and Read Write Process are given below, Please help me to make it work,

-----------------------------------------------------------------------------------------------------------------

 /* SPI2 parameter configuration*/

 hspi2.Instance = SPI2;

 hspi2.Init.Mode = SPI_MODE_MASTER;

 hspi2.Init.Direction = SPI_DIRECTION_2LINES;

 hspi2.Init.DataSize = SPI_DATASIZE_8BIT;

 hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;

 hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;

 hspi2.Init.NSS = SPI_NSS_SOFT;

 hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;

 hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;

 hspi2.Init.TIMode = SPI_TIMODE_DISABLE;

 hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

 hspi2.Init.CRCPolynomial = 10;

 if (HAL_SPI_Init(&hspi2) != HAL_OK)

 {

  Error_Handler();

 }

/* User Code*/

uint8_t sEEstatus[1] = { 0x00 };

uint8_t command[1] = { EEPROM_RDSR };// EEPROM_RDSR =0x05 

   // Send "Read Status Register" instruction

   if (HAL_SPI_Transmit(&hspi2, (uint8_t*)command,1, 200) != HAL_OK) {

       Error_Handler();

     }

   // Loop as long as the memory is busy with a write cycle

   do {

     while (HAL_SPI_Receive(&hspi2, (uint8_t*)sEEstatus, 1, 200) == HAL_BUSY) {

       HAL_Delay(1);

     };

     HAL_Delay(1);

   } while ((sEEstatus[0] & EEPROM_WIP_FLAG) == SET);

// Write in progress

------------------------------------------------------------------------------------------------------

Status is always 0xFF i.e. not reading the data from eeprom

Please correct me if my code is wrong.

schematic for reference:

thanks,

pratheep

    This topic has been closed for replies.
    Best answer by Pierre P.

    ​Hi,

    /CS=1 means eeprom deselected.

    To select the eeprom, you must pass /CS=1 to /CS=0 before starting communication. The transition high to low is mandatory.

    If you always keep /CS=0 , you can't have communication master vs eeprom.

    3 replies

    Graduate II
    June 22, 2020

    Chip select managed where?

    pratheepAuthor
    Visitor II
    June 24, 2020

    0693W000001rPUfQAM.pngChip Select is Connected to Ground.

    ST Employee
    July 1, 2020

    ​Hello

    /CS must be with pull-up &  managed by the µc.

    If always connected to GND, the device can be selected. That's why you read always 0xFF.

    See datasheet section 3.4  here : https://www.st.com/resource/en/datasheet/m95512-w.pdf

    BR

    Team EEPROM suPPort

    pratheepAuthor
    Visitor II
    July 3, 2020

    Hi, I'm using only one slave on spi channel . So, is that wrong to keep pull down by default?

    Thanks,

    Pratheep

    Pierre P.Answer
    ST Employee
    July 3, 2020

    ​Hi,

    /CS=1 means eeprom deselected.

    To select the eeprom, you must pass /CS=1 to /CS=0 before starting communication. The transition high to low is mandatory.

    If you always keep /CS=0 , you can't have communication master vs eeprom.

    pratheepAuthor
    Visitor II
    July 6, 2020

    Thank you!