User`s manual

Rabbit 4000 Designer’s Handbook rabbit.com 67
7.2.4 Writing the User Block
writeUserBlock
int writeUserBlock(unsigned addr, void *source, unsigned numbytes);
DESCRIPTION:
Rabbit-based boards are released with System ID blocks located on the primary flash. Version 2
and later of this ID block has a pointer to a User block that can be used for storing calibration con-
stants, passwords, and other non-volatile data. This block is protected from normal writes to the
flash device and can only be accessed through this function. This function writes a number of
bytes from root memory to the User block
NOTE: Portions of the User block may be used by the BIOS for your board to store values
such as calibration constants! See the manual for your particular board for more information
before overwriting any part of the User block.
Backwards Compatibility:
If the version of the System ID block doesn't support the User block, or no System ID block is
present, then the 8 KB starting 16 KB from the top of the primary flash are designated the User
block area. However, to prevent errors arising from incompatible large sector configurations, this
will only work if the flash type is small sector. Rabbit manufactured boards with large sector flash
will have valid System and User ID blocks, so this should not be problem on Rabbit-based boards.
If users create boards with large sector flash, they must install System ID block version 3 or great-
er to use this function, or modify this function.
PARAMETERS
addr Address offset in User block to write to.
source Pointer to destination to copy data from.
numbytes Number of bytes to copy.
RETURN VALUE
0: Successful
-1: Invalid address or range
-2: No valid User block found (block version 3 or later)
-3: Flash writing error
LIBRARY
IDBLOCK.LIB