
EPC-26A/27 Hardware Reference
Page 42
6
6
SRAM Standard Memory Array
Typically, access to the SRAM is via a file system installed by the device
driver
SRAMDISK.SYS
. For users who wish to bypass the file system and
use the SRAM as a standard memory array, the following ANSI C routine is
provided as an example of how to program an executable file.
#include <stdio.h>
#include <memory.h>
#include <conio.h>
typedef unsigned char UCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
#define FAR
_far
#define BYTESPERSECTION 0x100
#define EXMID
0x96
#define EXMENABLE
0x00000001
#define LSWLOWBYTE
0x8380
#define LSWHIGHBYTE
0x8381
#define MSWLOWBYTE
0x8382
#define MSWHIGHBYTE
0x8386
#define SRAMDATA
0x8384
UCHAR
Slot
=
5;
/* presumes Flash is in slot 5 */
void
readsection(UCHAR FAR *target, ULONG sramoffset)
{ UCHAR ob;
register USHORT rinductor;
/*
// Enable the card to allow register access
*/
outp(EXMID,Slot);
ob = inp(0x102);
outp(0x102,ob | EXMENABLE);
/*
// Load initial offset value (sramoffset should be
// divisible by 256)
*/
outp(MSWHIGHBYTE,(USHORT) (sramoffset >> 24));
outp(MSWLOWBYTE,(USHORT) (sramoffset >> 16));
outp(LSWHIGHBYTE,(USHORT) (sramoffset >>8));
outp(LSWLOWBYTE,(USHORT) sramoffset);
/*
// Read a section using the autoincrement feature.
*/
for (rinductor = 0; rinductor < BYTESPERSECTION; ri+) {
*+ = (UCHAR) inp(SRAMDATA);
}
outp(0x102,ob);
/* restore the option byte */
}
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com