Mikroelektronika MIKROE-442 데이터 시트
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
347
FLASH_Read
FLASH_Read_Compact
Prototype
sub procedure FLASH_Read(dim address as longint, dim byref write_to as
word[100], dim NoWords as word)
Description Reads required number of words from the flash memory in the “regular” mode.
Parameters -
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
Example
dim Buffer as word[10]
start_address as 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
sub procedure FLASH_Read_Compact(dim address as longint, dim byref write_to
as byte[100], dim NoBytes as word)
Description Reads required number of bytes from the flash memory in the “compact” mode.
Parameters -
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
Example
dim Buffer as byte[10]
start_address as 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 flash are being used.