1

I'm trying to communicate through SPI to a Flash ROM chip (M45PE20) with an ATMEGA 2560. I'm looking to read the data off the chip, but the output I'm getting is nothing but FF's. I've checked my wiring and everything looks okay on that end, I also don't have a scope to probe the output unfortunately.

I've the crude code below:

void setup() {
  Serial.begin(9600);
  pinMode(SS, OUTPUT);
  digitalWrite(SS, HIGH);
  SPI.begin();
}

void loop() {
  Serial.println("Starting");
  Serial.println("Waiting 1s");
  delay(1000);
  SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));

  digitalWrite(SS, LOW);
  Serial.println(SPI.transfer(0x03));
  Serial.println(SPI.transfer(0x00));
  Serial.println(SPI.transfer(0x00));
  Serial.println(SPI.transfer(0x00));
  for (int i = 0; i < 16384; i++) {
    Serial.print(i * 32, HEX);
    Serial.print(" ");
    for (int j = 0; j < 32; j++) {
      Serial.print(SPI.transfer(0xFF), HEX);
      Serial.print(" ");
    }
    Serial.println();
  }

  Serial.println();
  digitalWrite(SS, HIGH);
  delay(500);
  SPI.endTransaction();
  delay(5000);
}

Link to datasheet: https://drive.google.com/file/d/1_Zlg-hb5B08u7_m_N4_addmmjyv_nANS/view?usp=sharing

Picture of specific read command from datasheet: Picture of specific read command from datasheet.

2
  • Can you provide a wiring diagram? Also, a blank/new chip will be full of 0xFF.
    – user85471
    Commented May 24, 2021 at 3:31
  • I will update my post tomorrow evening, this is part of a game cartridge so the wiring is going to be a bit weird looking. I can also confirm that the chip is filled with random data, and not full of 0xFF. Commented May 24, 2021 at 3:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.