AnsweredAssumed Answered

Winbond Flash - W25Q80BV Write Issues

Question asked by Brinda Vadaliya on Dec 7, 2017
Latest reply on Dec 11, 2017 by avi_crak.videocrak

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;
}

Outcomes