Hi all,
I need to use the 23A256 RAM with my Arduino Mega using SPI interface.
Attached please find the schematic which I implemented. I used appropriate resistor-based voltage dividers to make sure I apply appropriate (1.5-1.9V) supply voltage to 23A256 RAM.
I downloaded the library (spiRAM3a.zip) from Arduino Playground - SpiRAM
However, when I run the "Test" example of the library I get the attached error, and when I run the "Example" example of the library I get no results at all.
Now I wonder whether I made the schematic wrong, or there is something wrong with the library.
In the examples I just changed the SS_PIN from 10 to 53, as pin 53 is the slave select pin of Mega.
There is a variable named "A5" in "Test" example, which was unclear for me.
I would highly appreciate if anyone can help.
Below please find the codes of both examples.
// Test example
#include <SPI.h>
#include <SpiRAM.h>
#define SS_PIN 53 //this was 10 in original example code
byte clock = 0;
SpiRAM spiRam(0, SS_PIN);
void setup() {
digitalWrite(A5, HIGH);
Serial.begin(115200);
delay(1000); // wait for a second
Serial.println("Version 1");
}
// The RAM, initially having random contents, will fail the test. If A5 is
// pulled to ground, the correct value will be written before test, and the
// RAM location written to, will pass the test. Keeping A5 low for the full
// cycle from 0 to 7FFF will make the test completely happy. Until the next
// next power cycle.
void loop() {
unsigned int address = 0;
unsigned int i;
unsigned int maxRam = 32768;
byte wValue, rValue;
for (i=0; i < maxRam; i++) {
wValue = (byte) (i & 0xFF);
if (digitalRead(A5) == LOW) {
spiRam.write_byte(i, wValue);
}
rValue = (byte)spiRam.read_byte(i);
if (wValue != rValue) {
Serial.print("RAM error at ");
Serial.print(i, HEX);
Serial.print(" should be ");
Serial.print(wValue, HEX);
Serial.print(" is ");
Serial.println(rValue, HEX);
} else {
Serial.println(i, HEX);
}
}
}
//Example example
#include <SPI.h>
#include <SpiRAM.h>
#define SS_PIN 53 //this was 10 in original example code
byte clock = 0;
SpiRAM SpiRam(0, SS_PIN);
void setup() {
Serial.begin(9600);
}
void loop()
{
char data_to_chip[17] = "Testing 90123456";
char data_from_chip[17] = " ";
int i = 0;
// Write some data to RAM
SpiRam.write_stream(0, data_to_chip, 16);
delay(100);
// Read it back to a different buffer
SpiRam.read_stream(0, data_from_chip, 16);
// Write it to the serial port
for (i = 0; i < 16; i++) {
Serial.print(data_from_chip[i]);
}
Serial.print("\n");
delay(1000); // wait for a second
}




