Site Index
   Home
   File Upload
Google

Transfer Site
Main Site

EVM5502 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:

Function Description
EVM5502_FLASH_checksum Calculate checksum for a memory range
EVM5502_FLASH_erase Erase a range of Flash memory
EVM5502_FLASH_read Read data from a range in Flash
EVM5502_FLASH_write Write data to a range in Flash

Programs that use the FLASH API should include both the evm5502.h and the evm5502_flash.h BSL header files. evm5502_flash.h defines several constants that may be useful while programming:

Name Typical Value Description
EVM5502_FLASH_BASE 0x200000 Address of start of Flash memory
EVM5502_FLASH_PAGESIZE 0x8000 Size of a normal Flash page
EVM5502_FLASH_PAGES 8 Number of EVM5502_FLASH_PAGESIZE pages
EVM5502_FLASH_SIZE 0x40000 Total size of Flash
EVM5502_FLASH_SUPPORT 1 1 if Flash is supported on this target, 0 if not

EVM5502_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
evm5502.h
evm5502_flash.h

Required Libraries
evm5502bsl.lib

Function Prototype
Uint32 EVM5502_FLASH_checksum( Uint32 start, Uint32 length )

Parameters
start - Beginning of region to erase. 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 = EVM5502_FLASH_checksum(EVM5502_FLASH_BASE, EVM5502_FLASH_PASESIZE);


EVM5502_FLASH_erase()

Description
Erase a range of Flash memory.

Required Headers
evm5502.h
evm5502_flash.h

Required Libraries
evm5502bsl.lib

Function Prototype
void EVM5502_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 */
    EVM5502_FLASH_erase(EVM5502_FLASH_BASE, 
                        (Uint32)(EVM5502_FLASH_PAGESIZE * 2));

    /* Erase the entire Flash */
    EVM5502_FLASH_erase(EVM5502_FLASH_BASE, EVM5502_FLASH_SIZE);

EVM5502_FLASH_read()

Description
Read data from a range in Flash

Required Headers
evm5502.h
evm5502_flash.h

Required Libraries
evm5502bsl.lib

Function Prototype
void EVM5502_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 */
    EVM5502_FLASH_read(EVM5502_FLASH_BASE, (Uint32)buf, 256);

EVM5502_FLASH_write()

Description
Write data to a data range in Flash. The Flash must be erased first.

Required Headers
evm5502.h
evm5502_flash.h

Required Libraries
evm5502bsl.lib

Function Prototype
void EVM5502_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 */
    EVM5502_FLASH_write((Uint32)buf, EVM5502_FLASH_BASE, 256);
©Copyright 2002-2011 Spectrum Digital, Inc. All Rights Reserved.