1.17.4 Erase Flash Command

This command erases the number of flash PAGES in the length field. The actual size of the page depends upon the device being programmed. The address must be the beginning address of the first page to be programmed. In addition, attempting to erase memory outsize the application space will result in a Invalid Address (0xFE) status. The correct unlock sequence must be sent to the part for each command as it is not stored on the device

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x03) - Erase Program Memory

2

Length

uint16_t

Number of pages to erase. Low Byte First

4

Unlock Seqeunce

uint32_t

Unlock sequence for flash. Key for currently supported parts is 0x00AA0055

4

Address

uint32_t

Address of the first memory location to erase. Must be page aligned. Low byte first.

Erase Command Response Format

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x03) - Erase Program Memory

2

Length

uint16_t

Number of pages to erase. Low Byte First

4

Unlock Seqeunce

uint32_t

Unlock sequence for flash. Key for currently supported parts is 0x00AA0055

4

Address

uint32_t

Address of the first memory location to erase. Must be page aligned. Low byte first.

1

Status

uint8_t

Status of Command
  • 0x01 Success

  • 0xFF Unsupported command

  • 0xFE Invalid Address

 

 

Example Sequence

Erase two pages of flash starting at address 0x000A000. All values in Hex

Example command to the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x03

2

Length

uint16_t

0x0002

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00A000

Example as viewed on bus: 0x03, 0x02, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x00, 0xA0, 0x00, 0x00

 

<erase_command_example_response Erase Example Response Sequence

Example reponse from the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x01

2

Length

uint16_t

0x0002

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00A000

1

Status

uint32_t

0x01

Example as viewed on bus: 0x03, 0x02, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x01