Hey guys,
I have an external memory chip that i bought. It's the 23K640 from microchip and i would like to connect it to my Arduino Mega 2560, which apparently can support this external memory of 64K, however i can't make heads or tails of the mega's data sheet or the chips despite reading it over and over. They just repeatedly keep saying how it is supported and they work really well together, just not how they connect.
The chip has 8 pins
CS (bar) - chip select input
SO - serial data output
Vss - GND
SI - serial data input
SCK - serial clock input
HOLD (bar) - hold input
Vcc - Supply voltage
NC - haven't been able to find out what this one is.
If anyone could please shed some light on to how i should connect this chip to the the Arduino i'd be really appreciative. Thank you for reading
You have a serial memory that runs a voltage of about 3.3V or so. You'll need to use interface hardware to connect it safely to the 5V Mega 2560. Nick Gammon has a detailed page describing how to connect a similar EEPROM. It's not exactly what you'll do, but it will give you a clear picture of what you need to understand, and later do, to hook up this memory. See the page here: Gammon Forum : Electronics : Microprocessors : Connecting 512 Kbyte EEPROM (flash memory) to your processor using SPI
Thanks guys,
So from what i've understood from jremington's doc is that
MOSI is pin 51 which connects to SI
MISO is pin 50 that connects to SO
SCK is pin 52
and i think SS connects to CS (bar) with pin 53
and NC is nothing
then tmd3's post helped me understand that the hold doesn't need to be connected to anything and the powering.
What i now have a problem with is that those pins are already used by an SD card module that i'm using. Is there a way to make those four connection pins different so i can have both the external RAM and the SD card?
The SD card module should also have a SS or CS (slave select or chip select) line. All you have to do is enable the one you want to talk to and disable the other, and talk to it. The SD card module and the IC will have a pin each and the MISO, MOSI, and SCK will all be bussed from the Arduino to both these devices. See this image:
That's SPI RAM. Rugged Circuits sells direct address external RAM for the Mega2560. It looks like internal RAM at a 1 cycle penalty. However you can only access 56K of each 64K bank since the internal 8K masks the lower 8K addresses. The internal 8K gets used for stack, the selectable 56K banks get used for heap.
Access is through 2 8 bit ports and some other pins. You do lose quite a few pins. The board plugs into the headers at the end of the board away from the USB plug.
Access is DIRECT parallel. It looks the same as internal RAM. The AVR family that the 2560 comes from can do this and IIRC no others have the true direct address feature. The chip you bought can be used by any AVR, even the UNO's 328P.
I got the Rugged Circuits 512K board for $25 plus $3-something shipping. I can use 8 banks x 56K of that which really ain't shabby.
On the up side, the chip you got can hook up to MEGA/UNO/Leonardo/Micro/etc Arduinos which makes it and what you are doing pretty much Universal and I am sure costs less!
Awesome thanks guys,
JoeN I understand your diagram for the slave select, and am actually trying it out, but i think it's a rather ineffective solution because every time i select the SD card again it has to reinitialise. To have them running simultaneously, would i be able to use the MISO and MOSI on the ICSP to the same effect? That way i could have them running off a common clock, two separate SS pins and their own individual MISO/MOSI pins.
Am i able to do that? If not please explain why
You won't be able to run SD and SPI RAM on the same bus at the same time.
Atmel AVR docs do say that AVR serial ports can be used as master-mode SPI however. But I have not seen a library for that, only for the 1-only universal SPI port. It is possible but not so easy?
The Mega2560 has 3 extra serial ports. The 1284P chip has 1 extra.
You can also look into soft SPI. That is where the CPU drives pins the same way as SPI port but without the nice hardware to do most of the work. You can try that if you find SoftSPI library. However I don't think that AVR chips have the speed to run a full speed hardware SPI channel and soft SPI channel at the same time but you would save the initialization, it might be worth the effort.