Skip to main content

spiflash.erasesector(sectorAddress)

Erases a 4KB sector of the SPI flash

Availability

Device

Parameters

Name Type Description
sectorAddress Integer The address of the 4KB sector to be erased

Returns

Nothing

Description

This method causes the erasure of an entire sector of the SPI flash storage, setting each bit in the sector to 1.

Every sector is 4KB long and arranged on 4KB boundaries, ie. beginning at addresses 0x0000, 0x1000, 0x2000 and so on. Calling this method with an address that is not on a 4KB boundary will cause a Squirrel error to be raised. With the imp003, imp004m, imp005 and imp006, you must fit a SPI flash chip which supports 4KB erases; the imp005 SPI flash must also support 64KB erases.

If for any reason a sector has been hardware protected — set to read-only mode — in the manufacturing process, this call will fail.

Example Code

Erase the first 12KB of the SPI flash storage.