how-to-erase-and-overwrite-data-in-spi-eeprom

Thread Starter

rmrps

Joined Feb 24, 2012
21
I am using WinBond W25Q64JV SPI Flash chip for storing data and micro controller is STM32F101RCT6. When i am try to store the data in Winbond chip it is working fine i can able to read and write data in winbond chip but if i want to overwrite the new data in same address it is not overwrite and it is giving the old data that is new data is not written in same memory.If i use the erase option it is erase all data in all address location i am unable to erase particular address data. After all address data erased i can able to write the new data but i am losing the data in all other locations so please guide me to overwrite the new data in same address location/ Erase option for particular address my code is below

HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_RESET);
Spi_data[0]=0x06; //Write Enable
HAL_SPI_Transmit(&hspi2,Spi_data,1,1000);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_RESET);
Spi_data[0]=0x02; //Page Program
Spi_data[1]=0x00;
Spi_data[2]=0x10;
Spi_data[3]=0x14;
Spi_data[4]=0x43;
HAL_SPI_Transmit(&hspi2,Spi_data,5,10000);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_SET);

HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_RESET);
Spi_data[0]=0x03;//Read Data
Spi_data[1]=0x00;
Spi_data[2]=0x10;
Spi_data[3]=0x14;
HAL_SPI_Transmit(&hspi2,Spi_data,4,100);
HAL_SPI_Receive(&hspi2,GSdata,4,100);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_SET);

when i am try to overwrite the new data in 0x1014 location it is not overwritten if i am use the following erase option it is erase all memory address data

HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_RESET);
Spi_data[0]=0x20;//Erase
Spi_data[1]=0x00;
Spi_data[2]=0x10;
Spi_data[3]=0x14;
HAL_SPI_Transmit(&hspi2,Spi_data,4,1000);
HAL_GPIO_WritePin(CHIP_SELECT_GPIO_Port, CHIP_SELECT_Pin, GPIO_PIN_SET);

please guide me to overwrite the new data in same address/Erase option for particular address
 
Top