User manual

mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
345
FLASH_Read
FLASH_Read_Compact
Prototype
procedure FLASH_Read(address : longint; var write_to : array[100] of word;
NoWords : word);
Description Reads required number of words from the ash memory in the “regular” mode.
Parameters - address: starting address of the FLASH memory block to be read
- write_to: starting address of RAM buffer for storing read data
- NoWords: number of words to be read
Returns Address of RAM buffer for storing read data.
Requires
Example
var Buffer : array[10] of word;
start_address : longint;
...
FLASH_Write(0x006500, data);
start_address := 0x6500;
FLASH_Read(start_address, Buffer, 10);
Notes The user should take care of the address alignment (see the explanation at the beginning of this
page).
Prototype
procedure FLASH_Read_Compact(address : longint; var write_to : array[100]
of byte; NoBytes : word);
Description Reads required number of bytes from the ash memory in the “compact” mode.
Parameters - address: starting address of the FLASH memory block to be read
- write_to: starting address of RAM buffer for storing read data
- NoBytes: number of bytes to be read
Returns Address of RAM buffer for storing read data.
Requires
Example
var Buffer : array[10] of byte;
start_address : longint;
...
FLASH_Write(0x006500, data);
start_address := 0x6500;
FLASH_Read(start_address, Buffer, 10);
Notes The user should take care of the address alignment (see the explanation at the beginning of this
page).
Library Example
In this example written for dsPIC30F4013, various read/write tecniques to/from the on-chip FLASH memory are shown.
Flash memory is mapped to address space 3:2, meaning every 3 consecutive bytes of Flash have 2 consecutive
address locations available.
That is why mikroE’s library allows data to be written to Flash in two ways: ‘regular and ‘compact’. In ‘regular mode,
which is used for variables that are size of 2 bytes and more, the 3rd (un-addressable) byte remains unused.
In ‘compact’ mode, which can be used for 1 byte-sized variables/arrays, all bytes of ash are being used.