greetings all,
im having trouble getting this eeprom to work correctly - x5045 Renesas Electronics Corporation - it takes a 9 bit address i think "datasheet - page 8, table 1 instruction set. i was able to write a value to addr 0 and read it, but thats the only address i can see, i used the following sketch because of the 9 bits, but this is the only way it works for that one address, cant see any others, obviously i have no idea what im doing wrong, any advice please?
#include <SPI.h>
#define WRITE 2
#define READ 3
#define WREN 6
#define RDSR 5
#define WRSR 1
unsigned int address = 0x00;
byte outval = 243;
byte invalue;
void setup(){
Serial.begin(9600);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV4); // max clock is 20MHz, so can set high speed
SPI.begin(); // sets up pin modes etc.
// Enable writing
digitalWrite(SS, LOW);
SPI.transfer(WREN);
digitalWrite(SS, HIGH);
digitalWrite(SS, LOW);
SPI.transfer(READ); // read instruction
SPI.transfer(address >> 16) ;
SPI.transfer(address >> 8 );
SPI.transfer(address );
invalue = SPI.transfer(0); // Clock out the data
digitalWrite(SS, HIGH);
Serial.print(F("Read Data = "));
Serial.println(invalue,DEC);
}
void loop(){}
im also working on this, i would have just thrown the chip aside by now usually, but i soldered it (soic8) on an adapter board (5 for $5.95 adafruit) so its kind of a challenge, ill never be able to figure this out on my own though, but im trying
Pinout looks good - you have decoupling on the chip? You need it. Keep the SPI wiring short and bundled
together with the ground/supply wires for good measure.
Also when talking to a new SPI chip like this the first thing to do is read the any status registers and
see if the bits coming out make sense. Once thats working you have confidence the basic comms
is functioning - one step at a time is how things are made to work... Be methodical and check everything
twice - its surprising how often that fixes things.
Then for a memory chip implement READ - the inital values for EEPROMs are usually all 0xFF, check
its returning what is expected.
Then implement WRITE - if you think you've got write working on address 0, write a 0xAA (or any unique
pattern you will recognise) and read back all the memory - this will tell you for sure what's working.
leads are about 3 inches, tried everything you said, its only writing the first value (using a for loop to write a few different values) and reading that value back no matter how many address' i cycle through. i really appreciate you guys trying to decipher this but maybe ill order some i2c 256kbit eeproms and just nix the cpu supervisor all together, too bad PaulS or Nick Gammon wont comment i bet you they can figure it out in about 10 seconds
you know if it wasnt for Nick Gammon's website alot of my projects wouldnt be, he answers just about everything ive ever wondered how to do with my arduino. thanks Nick for sharing the knowledge. today im dumping a bootloader on a blank atmega328p using Mr. Gammon's method/sketch. Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer