WRITE
 
Syntax


FUNCTION WRITE ( FlashAddr, Source, subblocksize

Source  arrayname | stringname 

subblocksize = 0 | 256* | 512 | 1024 | 2048 | 4096 | 8192*

Description -- added version 7.13


WRITE copies data into the Flash memory space shared with the user code Flash space. Generally space above 0x4000 is available, but there is no protection for writing over your program.  Flash is organized in sectors, 4K in ARMmite, ARMexpressLITE, 8K sectors in the ARMexpress, the ARMweb has a mix of 4K and 32K sectors.   (details in the NXP User Manual).

Writing consists of erasing the whole sector and then writing a subblock or all.

Erases will erase the entire sector.

subblocksize portions may be written (ARMexpress allows upto 8K but not 256).  FlashAddr must be alligned to subblocksize.

Data is copied from a string or array to the Flash.  Only fixed subblocksize sizes are allowed. This function does not look for 0 terminators when a string is the source.

To force a sector to be erased use a block size of 0.  Once a portion is written after an erase, it can not be written again without being erased.

WRITE assumes that the sector is to be erased when first written, or when the same subblock as the last call to WRITE is being written.  When different subblocks of the same sector are being written, an erase will only occur when WRITE is called with a subblocksize of 0.  The WRITE routine only keeps track of which sector and sublock were last written, you must manage sectors

These routines call the IAP routines for write, erase and prep commands.  More details in the user manual for the corresponding CPU.

0 is returned on success, Non-zero error code when there is an error refer to IAP section in CPU user manual for definitions .

Example

'  simple example of write and read
DIM A(511) as string
DIM B(511) as string
...

WRITE (&H6000, A, 512)   ' this will erase the &H6000 sector, as its the first encountered
WRITE (&H6200, A, 512)   ' no erasure is required, as it was erased in the last call

...

WRITE (&H6000, A, 0)       ' this forces an erase of sector &H6000, needed as it was the last sector erased
WRITE (&H6000, A, 512)   
...
WRITE (&H6000, A, 512)    ' as the same block is being written it will automatically be erased


Differences from other BASICs

 

See also