1.17.2 Read Flash Command

This command will read the program flash and return the data read in the response packet. Because of the flash architecture, flash must always be read in modulus 4 byte lengths and the address must also be modulus 4 bytes or on PIC24/dsPIC33 instruction boundaries. The address of the memory range must reside entirely within the application space. If any of the requested data is outside of the application space, a status of 0xFE, Invalid Address, with no data will be returned.

read_command_format Read Command Format

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x01) - Read Program Memory

2

Length

uint16_t

Number of bytes to read. Length must be modulus 4 in length.

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 read. Address must modulus 4 bytes.

 

Read Command Response Format

Field Size

Description

Data Type

Comments

1

Cmd

uint8_t

Command (0x01) - Read Program Memory

2

Length

uint16_t

Number of bytes to read.

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 read. Must be modulus of 4 bytes.

1

Status

uint8_t

Status of Command
  • 0x01 Success

  • 0xFF Unsupported command

  • 0xFE Invalid Address

 

Command Example Sequence

Read 8 bytes of data (0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08) starting at address 0x00001878. All values in Hex

Example command to the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x01

2

Length

uint16_t

0x0008

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00001878

Example as viewed on bus: 0x02, 0x08, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x78, 0x18, 0x00, 0x00

Response Example Response Sequence

Example reponse from the device

Field Size

Description

Data Type

Value

1

Cmd

uint8_t

0x01

2

Length

uint16_t

0x0008

4

Unlock Seqeunce

uint32_t

0x00AA0055

4

Address

uint32_t

0x00001878

1

Status

uint32_t

0x01

8(for this example)

Read Data from device

uint8_t

0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08

Example as viewed on bus: 0x02, 0x08, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x78, 0x18, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08