AnsweredAssumed Answered

M95M02 SPI based EEPROM Read and Write issue.

Question asked by pankaj kyada on Nov 17, 2017
Latest reply on Nov 17, 2017 by KIC8462852 EPIC204278916

i am facing the write and read issue in M95M02 EEPROM, i am follow the read write cycle as per data sheet.

but not write and read in EEPROM.

MCU: STM32F105RB.

my read write algorithm in below.

/************************************WRITE Algorithm******************************/

/**
  * @brief  Transmit a byte of data in blocking mode.
  * @param  addr: Data addresh
  * @param  ptr_dat: Pointer to data buffer
  * @retval HAL status
  */
HAL_StatusTypeDef EEPROM_Byte_Write(uint8_t *ptr_dat, uint32_t addr)
{
  HAL_StatusTypeDef status = HAL_OK;
  uint8_t temp = 0x00, *ptr_temp = '\0';
 
  /* Send Write Enable Command */
  CHIP_SEL_RESET();       // Chip select Low
  temp = (uint8_t)WREN;
  HAL_SPI_Transmit(&hspi1, &temp, 1, 10);
  HAL_Delay(10);
  CHIP_SEL_SET();         // Chip select High
 
  /* Send Write To Memory Array Command */
  CHIP_SEL_RESET();       // Chip select Low
  temp = (uint8_t)WR;
  HAL_SPI_Transmit(&hspi1, &temp, 1, 10);        
   
  /* EEPROM 24 Bit Addresh Send */    
  ptr_temp = (uint8_t *)&addr;  
  HAL_SPI_Transmit(&hspi1, ptr_temp, 3, 10);            
   
  /* Sending One Byte In EEPROM */
  status = HAL_SPI_Transmit(&hspi1, ptr_dat, 1, 10);
 
  /* Send Write Disable Command */
  temp = (uint8_t)WRDI;
  HAL_SPI_Transmit(&hspi1, &temp, 1, 10);
 
  CHIP_SEL_SET();         // Chip select High    
 
  return status;
}

/*************************************************************************************/

/************************************READ Algorithm*******************************/

/**
  * @brief  Receive a byte of data in blocking mode.
  * @param  addr: Data addresh
  * @param  ptr_dat: Pointer to data buffer
  * @retval HAL status
  */
HAL_StatusTypeDef EEPROM_Byte_Read(uint8_t *ptr_dat, uint32_t addr)
{
  HAL_StatusTypeDef status = HAL_OK;
  uint8_t temp = 0x00, *ptr_temp = '\0';
    
  /* Send Read To Memory Array Command */
  CHIP_SEL_RESET();       // Chip select Low                                          
  HAL_Delay(10);                                          
  temp = (uint8_t)RD;
  HAL_SPI_Transmit(&hspi1, &temp, 1, 10);
 
  /* EEPROM 24 Bit Addresh Send */    
  ptr_temp = (uint8_t *)&addr;  
  HAL_SPI_Transmit(&hspi1, ptr_temp, 3, 10);
 
  /* Receving One Byte From EEPROM */
  status = HAL_SPI_Receive(&hspi1, ptr_dat, 1, 50);  

 

  CHIP_SEL_SET();         // Chip select High                                             
 
  return status;
}

/*************************************************************************************/

Outcomes