Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

rmrps

Member level 2
Member level 2
Joined
Oct 4, 2011
Messages
42
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,635
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

Code:
     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

Code:
   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
 

A memory sector is the smallest entity that can be erased individually. To rewrite smaller entities, you need to buffer the old sector content in RAM or copy it to a different sector.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top