cancel
Showing results for 
Search instead for 
Did you mean: 

Winbond Flash - W25Q80BV Write Issues

Brinda Vadaliya
Associate
Posted on December 07, 2017 at 10:52

I am working on STM32F100 with SPI Flash(Winbond - W25Q80BV) Interfacing. In my coding write page function, read page function, erase chip and erase sector function working properly. Status register also read properly.

But I can't write full flash. For write full flash I follow below step

1) First I erase chip 

2) Write page and then read page.

3) After that I increase address for move next page. But problem is that write only one page.I can't write into next page.

So I write only one page and read full flash but I got same data every time.

I want to read/write full flash. 

Below I mention my code (write function)

Please suggest me write Algorithm or step which is useful for write full flash.  

HAL_StatusTypeDef Flash_W25Q80_Page_Write(uint32_t Addr, uint8_t *data, uint16_t length)

{

uint8_t cmd_frm[4]={(uint8_t)FLASH_WRITE_CMD};

uint8_t stat_reg_ret[2]={0x00};

HAL_StatusTypeDef ret = HAL_OK;

cmd_frm[1]=(uint8_t)Addr >> 16;

cmd_frm[2]=(uint8_t)Addr >> 8;

cmd_frm[3]=(uint8_t)Addr;

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Read Status Register

Flash_W25Q80_Read_Status_Register(stat_reg_ret);

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Write Enable CMD Send

Flash_W25Q80_Write_Enable();

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Read Status Register

Flash_W25Q80_Read_Status_Register(stat_reg_ret);

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Send Page WRITE Cmd

ret = HAL_SPI_Transmit(&hspi1,cmd_frm,sizeof(cmd_frm),100);

if(ret != HAL_OK)

{

Error_Handler();

}

//Send 256 Byte data

ret = HAL_SPI_Transmit(&hspi1,data,length,1000);

if(ret != HAL_OK)

{

Error_Handler();

}

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Disable to Write

Flash_W25Q80_Write_Disable();

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//Read Status Register

Flash_W25Q80_Read_Status_Register(stat_reg_ret);

//Send CS Pin High->Low

Flash_W25Q80_CE_Toggle();

//CS_ENABLE;

return HAL_OK;

}
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on December 09, 2017 at 13:48

Shouldn't you poll the sFlash to find out when did it finished writing the data to given page?

If you start not with the 0th but with a different page, what's the result?

JW

View solution in original post

3 REPLIES 3
Posted on December 09, 2017 at 13:48

Shouldn't you poll the sFlash to find out when did it finished writing the data to given page?

If you start not with the 0th but with a different page, what's the result?

JW

Posted on December 11, 2017 at 07:12

I can write only one page from start with 0th location.

When I write from another location (not with 0th) , I can't write into the write buffer.

I face issues in multiple page write.

AVI-crak
Senior
Posted on December 11, 2017 at 08:53

Before writing data, you must:

1 consider the entire sector,

2 change the data,

3 erase the sector,

4 to record the first block,

5 Wait until the end of the recording,

6 repeat procedure 4 with the remaining blocks of the sector.

For smoother operation, you need to accumulate changes, and record after the first move beyond the used sector. You can save the data forcibly.

https://bitbucket.org/AVI-crak/flesh_25qxxx/overview