User manual

DSM tutorials
write enable pin (input)
status pin (output)
byte enable pin (input)
The device can operate in 16 bit data or 8 bit data mode. You select the mode using the byte enable
input. In 16 bit mode the Least Significant Bit (LSB) of the address bus is discarded. This example uses
the device in 16 bit mode so the byte enable is deactivated by wiring high (it is active low) and only the
most 22 most significant bits of the address bus are used. Each block inside the flash device contains
128 Kb. In 16 bit mode the blocks are 64 Kwords long. Of the total 23 address bits, the block address is
given by the most significant 6 bits and the address within a block is given by the least significant 17 bits.
The API requires functions for reading, writing and erasing data from the Flash device. Although the
device also features operations for querying device identity and locking blocks of data (to prevent them
from being erased) these are not essential for the operation of the device.
This example implements the interface translation code that converts API functions into device
operations using a server process that runs in parallel with an application. The API functions act as
clients to the server. The server is implemented using a non-terminating loop inside a macro procedure.
The API functions and the server use shared variables and a channel to communicate. These are
collected together inside a structure and passed as a parameter to the API functions and the server.
Here are the prototypes for the read, write and erase API functions:
/*
* Read datum from specified Address in flash into (*DataPtr)
* Parameters: FlashPtr : input of type (Flash)*
* Address : input of type (unsigned 22)
* DataPtr : input of type (unsigned 16)*
*/
extern macro proc FlashReadWord (FlashPtr, Address, DataPtr);
/*
* Write a datum from Data into Flash at specified Address
* Parameters: FlashPtr : input of type (Flash)*
* Address : input of type (unsigned 22)
* Data : input of type (unsigned 16)
*/
extern macro proc FlashWriteWord (FlashPtr, Address, Data);
/*
* Erase data from the block in the Flash referenced by BlockNumber
* Parameters: FlashPtr : input of type (Flash)*
* BlockNumber : input of type (unsigned 6)
*/
extern macro proc FlashEraseBlock (FlashPtr, BlockNumber);
The macro procedure containing the server has the following prototype:
/*
* Run the Flash device driver server
* Parameters: FlashPtr : input of type (Flash)*
* ClockRate : clock rate in Hz
*/
extern macro proc FlashRun (FlashPtr, ClockRate);
www.celoxica.com
Page 39