With regards to my earlier posting, I would like to get comments on the following. Note that DS00548C has bugs in it - the BCF ALUSTA,5 in each example should be followed by BSF ALUSTA,4 to set the increment mode properly. If anybody has a 17C ICE and can give this a test I'd really appreciate it - I have yet to get the hardware. Thanks. Andy /**************************************************************************** ** ** ** External RAM Access Routines ** ** ** ****************************************************************************/ // // This module provides an interface to permit a device to communicate // with external RAM and ROM for buffering messages, etc. // #ifndef CLRWDT #include "pic.h" #include "string.h" #endif #define EXTRAM_C #include "defs.h" // definitions of data types, etc. // //............................................................................ // // ram_write_block // // Copy block of register RAM to external SRAM. This routine handles the // blocking needed to write a large block of data. // // NOTE: This routines writes 16-bit values, not 8-bit bytes!!! // // INPUTS: // on stack - // External address to receive data (address) // Internal RAM address to read from (source[]) // Number of words to write (count) // // OUTPUTS: // on stack - number of bytes written // // Author: Andy Kunz // Date: 00-00-98 // Modifications: none // // Based on DS00548C // byte ram_write_block (UINT address, UINT source[], byte count) { byte i; // Index into source[] UINT element; TBLPTR = address; ALUSTA &= 0b10011111; // Set FS1:FS0 to auto-inc FSR0 ALUSTA |= 0b00100000; FSR0 = address; i = 0; do { asm ("tlwt 1,0"); asm ("tablwt 0,1,0"); // Write and increment } while (--count); } // //............................................................................ // // ram_read_block // // Read block of data from external RAM or ROM into internal RAM // // NOTE: This routines reads 16-bit values, not 8-bit bytes!!! // // INPUTS: // on stack - // pointer to destination (dest[]) // address of external RAM/ROM (address) // number of words to fetch (count) // // OUTPUTS: // data at dest[] updated in place // // // Author: Andy Kunz // Date: 00-00-98 // Modifications: none // // Based on DS00548C // void ram_read_block (UINT dest[], UINT address, byte count) { byte i; // Index into source[] TBLPTR = address; ALUSTA &= 0b10011111; // Set FS1:FS0 to auto-inc FSR0 ALUSTA |= 0b00100000; asm (" tablrd 1,1,_i"); i = 0; FSR0 = dest; // Point to destination do { asm (" tlrd 1,0"); // Read a byte & store asm (" tablrd 0,1,0"); // Read next byte & store } while (--count); } ================================================================== Andy Kunz - Statistical Research, Inc. - Westfield, New Jersey USA ==================================================================