cancel
Showing results for 
Search instead for 
Did you mean: 

M95512-D EEPROM with STM32F103RCT7 Communication is not working.

pratheep
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Pierre P.
Senior III

​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.

View solution in original post

6 REPLIES 6

Chip select managed where?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

0693W000001rPUfQAM.pngChip Select is Connected to Ground.

Pierre P.
Senior III

​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

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

Thanks,

Pratheep

Pierre P.
Senior III

​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.

Thank you!