nimaltd / spif

W25qxx, N25Qxx and other SPI FLASH driver for stm32 HAL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sector erase not working

YoulDHead opened this issue · comments

Hello!

I have w25q512 and sector erase function does not work for me.

I think we need to use 0x21 (Sector Erase (4KB) - with 4-Byte Address) opcode instead of 0x20 (Sector Erase (4KB)) in the W25qxx_EraseSector function, or provide 3-byte address

W25qxx_Spi(0x20);
if(w25qxx.ID>=W25Q256)
W25qxx_Spi((SectorAddr & 0xFF000000) >> 24);
W25qxx_Spi((SectorAddr & 0xFF0000) >> 16);
W25qxx_Spi((SectorAddr & 0xFF00) >> 8);
W25qxx_Spi(SectorAddr & 0xFF);

Cheers,
Youl

Similar errors in the W25qxx_WritePage and W25qxx_ReadPage functions.

For 3-byte address opcodes 4-byte addresses provided.

Hello. Could you solve it please and send to me. i don't have any board to test it yet. thanks

w25qxx.zip

All constructions like

W25qxx_Spi(0x0B); if(w25qxx.ID>=W25Q256) W25qxx_Spi((Page_Address & 0xFF000000) >> 24); W25qxx_Spi((Page_Address & 0xFF0000) >> 16); W25qxx_Spi((Page_Address& 0xFF00) >> 8); W25qxx_Spi(Page_Address & 0xFF);

Changed to

if(w25qxx.ID>=W25Q256){ W25qxx_Spi(0x0C); W25qxx_Spi((Page_Address & 0xFF000000) >> 24); }else{ W25qxx_Spi(0x0B); } W25qxx_Spi((Page_Address & 0xFF0000) >> 16); W25qxx_Spi((Page_Address& 0xFF00) >> 8); W25qxx_Spi(Page_Address & 0xFF);

i.e. for IC that have more than 256 Mbit we use proper opcodes.