EVM5509 Flash Module
The FLASH API provides functions to erase as well as read and write from the on-board Flash memory. Programming errors can be detected through use of a checksum function.
The following list summarizes the FLASH API in terms of its function calls:
Programs that use the FLASH API should include both the evm5509.h and the evm5509_flash.h BSL header files. evm5509_flash.h defines several constants that may be useful while programming:
| Name |
Typical Value |
Description |
| EVM5509_FLASH_BASE |
0x200000 |
Address of start of Flash memory |
| EVM5509_FLASH_PAGESIZE |
0x8000 |
Size of a normal Flash page |
| EVM5509_FLASH_PAGES |
8 |
Number of EVM5509_FLASH_PAGESIZE pages |
| EVM5509_FLASH_SIZE |
0x40000 |
Total size of Flash |
| EVM5509_FLASH_SUPPORT |
1 |
1 if Flash is supported on this target, 0 if not |
EVM5509_FLASH_checksum()
Description
Calculate the checksum of a data range in Flash. The checksum is the unsigned sum of all 16-bit words in the range. If the sum is exceeds 0xFFFFFFFF it wraps around at 32-bits. The sum is returned as a single 32-bit value.
Required Headers
evm5509.h
evm5509_flash.h
Required Libraries
evm5509bsl.lib
Function Prototype
Uint32 EVM5509_FLASH_checksum( Uint32 start, Uint32 length )
Parameters
start - Beginning of region to checksum. Given as an integral number of 16-bit words.
length - Length of memory to checksum. Given as an integral number of 16-bit words.
Return Value
32-bit checksum that is generated by adding all the bytes in the Flash range
Example
Uint32 checksum;
/* Calculate checksum for first page of Flash */
checksum = EVM5509_FLASH_checksum(EVM5509_FLASH_BASE,
EVM5509_FLASH_PASESIZE);
EVM5509_FLASH_erase()
Description
Erase a range of Flash memory.
Required Headers
evm5509.h
evm5509_flash.h
Required Libraries
evm5509bsl.lib
Function Prototype
void EVM5509_FLASH_erase( Uint32 start, Uint32 length )
Parameters
start - Beginning of region to erase. Given as an integral number of 16-bit words.
length - Length of region to erase. Given as an integral number of 16-bit words.
Return Value
None
Example
/* Erase the first 2 sectors of the Flash */
EVM5509_FLASH_erase(EVM5509_FLASH_BASE,
(Uint32)(EVM5509_FLASH_PAGESIZE * 2));
/* Erase the entire Flash */
EVM5509_FLASH_erase(EVM5509_FLASH_BASE, EVM5509_FLASH_SIZE);
EVM5509_FLASH_read()
Description
Read data from a range in Flash
Required Headers
evm5509.h
evm5509_flash.h
Required Libraries
evm5509bsl.lib
Function Prototype
void EVM5509_FLASH_read(Uint32 src, Uint32 dst, Uint32 length)
Parameters
src - Address of Flash to read from. Given as an integral number of 16-bit words.
dst - Address to memory to read to. Given as an integral number of 16-bit words.
length - Length of memory to read from. Given as an integral number of 16-bit words.
Return Value
None
Example
Uint8 buffer[256];
/* Copy 256 16-bit words from
* the beginning of the Flash to buf */
EVM5509_FLASH_read(EVM5509_FLASH_BASE, (Uint32)buf, 256);
EVM5509_FLASH_write()
Description
Write data to a data range in Flash. The Flash must be erased first.
Required Headers
evm5509.h
evm5509_flash.h
Required Libraries
evm5509bsl.lib
Function Prototype
void EVM5509_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
Parameters
src - Address of memory to read from. Given as an integral number of 16-bit words.
dst - Address to Flash to write to. Given as an integral number of 16-bit words.
length – Length of memory to write to. Given as an integral number of 16-bit words.
Return Value
None
Example
Uint8 buffer[256];
/* Copy 256 16-bit words from
* buf to the beginning of Flash */
EVM5509_FLASH_write((Uint32)buf, EVM5509_FLASH_BASE, 256);
|