beautypg.com

Erasing the flash, Request from host, Answers from bootloader – Rainbow Electronics AT89C5132 User Manual

Page 22

background image

22

AT89C5132

4256A–USB–06/03

Erasing the Flash

The flow described below allows the user to erase the Flash memory.

Two modes of Flash erasing are possible:

Full chip erase

Block erase

The Full Chip erase command erases the whole Flash (32 Kbytes) and sets some Con-
figuration Bytes at their default values:

BSB = FFh

SBV = FFh

SSB = FFh (NO_SECURITY)

The Block erase command erases only a part of the Flash.

Four Blocks are defined in the AT89C5132:

block0 (from 0000h to 1FFFh)

block1 (from 2000h to 3FFFh)

block2 (from 4000h to 7FFFh)

block3 (from 8000h to FFFFh)

Request From Host

To start the erasing operation, the Host sends a DFU_DNLOAD request with a Write
Command in the data field (2 bytes).

Answers from Bootloader

The device has two possible answers to a DFU_GETSTATUS request:

If the chip is protected from program access, a “err_WRITE” status is returned to the
Host.

Otherwise, the device status is “OK“.

The full chip erase is always executed whatever the Software Security Byte value is.

Command

Identifier

data[0]

data[1]

data[2]

data[3]

data[4]

Description

Id_write_command

04h

00h

00h

Erase block0 (0K to 8K)

20h

Erase block1 (8K to 16K)

40h

Erase block2 (16K to 32K)

80h

Erase block3 (32K to 64K)

FFh

Full chip erase (bits at
FFh)