External Memory Interface library for the Mega. (can someone review my code?)

I've just finished a library to use the External Memory Interface module on the Mega1280/2560. You can use it to access external memory via parallel address/data bus. The address bus width is from 8-bits upto 16-bits and the data bus width is 8-bits. You'll need a 74AHC573 transparent latch to multiplex the Port A address/data lines. I've tested the library with ti's bq3287EA RTC and an Atmel AT28HC256 EEPROM both connected. I could access the RTC as the lower sector and the EEPROM as the upper sector. The library has four functions; enable(), disable(), read() write(). The library can read/write to any valid data type (including string literals) to any external memory address. The lirary zip file is on google code here: http://code.google.com/p/arduino-exmem-library/downloads/list and attached below. If anyone can review my code or better yet test it out and let me know what they think, I would apreciate it. Enjoy! :wink:

Thanks for your time,
DigitalJohnson

ExMem.zip (5.51 KB)

Um. Why? I thought the whole point of the "external memory interface" (as opposed to using random IO ports to access a memory device) is that the memory appears in the AVR address space, and can be accessed via normal C code. There's a good summary accompanying the Rugged RAM expansion module: http://ruggedcircuits.com/html/megaram.html

And notes in avr-libc on how to set things up so that malloc() and friends will use it: Frequently Asked Questions

I guess your code handles the bank boundary "invisibly." But at great computational cost...

Thank you for the library. It is very nearly what I need to access some non memory devices only available with multiplexed address/data busses. http://mektronixtech.com/ My application uses 4 of these chips. Using malloc in this case would be a disaster. I need to read from and write to specific addresses. With partial addressing to control the CS lines of each chip, the code I am left to write is minimal. Any reason this wouldn't work with teensy2++? The chip is different, an AT90USB1286, but I think the register defines are the same. Leonardo might work too.

@slomobile
I looked at the data sheet for the AT90USB1286 and the register names are the same so it should work.

DJ