Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
341
FLASH_Write_Compact
FLASH_Write_Init
Prototype
sub  procedure  FLASH_Write_Compact(dim  flash_address  as  longint,  dim  data_
address as word, dim bytes as word)
Description Fills a portion of Flash memory using the dsPIC30 RTSP module, in the “compact” manner. In this way, 
several blocks of RTSP’s latch can be written in one pass. One latch block contains 4 instructions (8 
addresses, 12 bytes). Up to 8 latch blocks can be written in one round, resulting in a total of 8*12 = 96 
bytes. This method uses all available bytes of the program FLASH memory, including those that are 
not mapped to address space (every 3rd byte).
Parameters 
flash_address
: starting address of the FLASH memory block 
data_address
: data to be written 
bytes
: number of bytes to be written. The amount of bytes to be written must be a multiply of 12, 
since this is the size of the RTSP’s write latch(es). 
Returns
Nothing.
Requires
The block to be written to must be erased first, either from the user code FLASH_Erase32, or during 
the programming of MCU. Please note that block size that is to be erased is different from the one that 
can be written with this function!
Example
dim flash_address as longint
    cArr          as string[36]
    ptr_data      as word
...
flash_address = 0x006000
cArr = “mikroElektronika12mikroElektronika34”
ptr_data = @cArr
FLASH_Write_Compact(flash_address, ptr_data, 36)
Notes
The user should take care about the address alignment (see the explanation at the beginning of this 
page).
Prototype
sub procedure FLASH_Write_Init(dim flash_address as longint, dim data_address 
as word)
Description Initializes RTSP for write-to-FLASH operation.
Parameters 
flash_address
: starting address of the FLASH memory block 
data_address
: data to be written 
Returns
Nothing.
Requires
The block to be written to must be erased first, either from the user code FLASH_Erase32, or during 
the programming of MCU. Please note that block size that is to be erased is different from the one that 
can be written with this function!
Example
const iArr as word[8] = (“m”, “i”, “k”, “r”, “o”, “E”, “l”, “e”)
dim ptr_data as word
  ...
  ptr_data = @iArr
  FLASH_Write_Init(0x006100, ptr_data)
  FLASH_Write_Loadlatch4()
  FLASH_Write_Loadlatch4()
  FLASH_Write_DoWrite()
Notes
The user should take care about the address alignment (see the explanation at the beginning of this 
page).