AM29F400 Parallel Flash

Hey guys.

I'm working with an AM29F400 and want to read it out with Arduino MEGA.
I wired it up like this:
Data DQ0-DQ7 -> 22->29
Address A0-A16 -> 46->30 & A17 -> 7

So the Chip is response to me with correct Manufacturer ID and Device ID(Maybe interesting... If i ask the Chip with Byte Command like the Datasheet says it's responding to me with 00 both. Look picture), but my Data is every Read different. Some Bit Changing is going on or so. If i messed up my Address Pins or MSB/LSB it should give me every time the same data?

Here's my Code:

#define WE A9
#define OE A8
#define CS A3
#define RD0 22
#define RD7 29

byte AX_1[] = {46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 7};
void setCtrlPins();                                   //Setup control signals
void setAddrPinsOut();                                //Setup address signals
void setDigitalOut();                                 //Set D0-D7 as outputs
void setDigitalIn();                                  //Set D0-D7 as inputs
void setAddress(unsigned long addr);                  //Set Address across A0-A18
void setByte(byte out);                               //Set data across D0-D7
byte readByte();                                      //Read byte across D0-D7
void writeByte(byte data, unsigned long address);     //Write a byte of data at a specific address
void programData(byte data, unsigned long address);   //Executes the program command sequence
byte readData(unsigned long address);                 //Read data as specific address
void eraseChip();                                     //Executes the erase chip command sequece
void readSerialCommand(String in);                      //Decodes incomming serial commands


void setup()
{
  Serial.begin(115200);
  setDigitalIn();
  setCtrlPins();
  setAddrPinsOut();
  delay(2);
  Serial.println("Started Serial COM");
  //Chip Select Always LOW
  pinMode(CS, OUTPUT);
  digitalWrite(CS, LOW);
}

void loop()
{
  while (Serial.available()) {
    readSerialCommand(Serial.readStringUntil('\n'));
  }
}

void readSerialCommand(String in)
{
  if (in.indexOf("MID") >= 0) {
    Serial.print("Manufacturer ID: ");
    identManf();
  };
  if (in.indexOf("DID") >= 0) {
    Serial.println("CMD: D");
    Serial.print("Device ID: ");
    identDev();
  };

  if (in.indexOf("ReadAll") >= 0) {
    // Serial.println("CMD: A");
    // Serial.print("Read all: ");
    readallROM();
  };
}

void readallROM() {
  setDigitalIn();
  for (unsigned long d = 2000000; d < 3000000; d++) {
    int dadad = readData(d);
    if (dadad < 0x10)
    {
      Serial.print('0');
    }
    Serial.print(dadad, HEX);
  }
  Serial.println("End");
}

void identManf()
{
  setDigitalOut();
  writeByte(0xAA, 0x5555);
  writeByte(0x55, 0x2AAA);
  writeByte(0x90, 0x5555);
  delay(100);
  setDigitalIn();
  Serial.println(readData(0x0000), HEX);
}

void identDev()
{
  setDigitalOut();
  writeByte(0xAA, 0x5555);
  writeByte(0x55, 0x2AAA);
  writeByte(0x90, 0x5555);
  delay(100);
  setDigitalIn();
  Serial.println(readData(0x0001), HEX);
}

byte readData(unsigned long address)
{
  byte temp_read;
  digitalWrite(OE, HIGH);
  setAddress(address);
  delayMicroseconds(10);
  digitalWrite(OE, LOW);
  delayMicroseconds(150);
  temp_read = readByte();
  digitalWrite(OE, HIGH);
  return temp_read;
}

void writeByte(byte data, unsigned long address)
{
  digitalWrite(OE, HIGH);
  digitalWrite(WE, HIGH);

  setAddress(address);
  setByte(data);

  digitalWrite(WE, LOW);
  delayMicroseconds(30);
  digitalWrite(WE, HIGH);
}

void programData(byte data, unsigned long address)
{
  setDigitalOut();
  writeByte(0xAA, 0x5555);
  writeByte(0x55, 0x2AAA);
  writeByte(0xA0, 0x5555);
  writeByte(data, address);
  delayMicroseconds(30);
}

byte readByte()
{
  byte temp_in = 0;
  for (int i = 0; i < 8; i++)
  {
    if (digitalRead(RD0 + i))
    {
      bitSet(temp_in, i);
    }
  }
  return temp_in;
}

void setByte(byte out)
{
  for (int i = 0; i < 8; i++)
    digitalWrite( RD0 + i, bitRead(out, i) );
}

void setAddress(unsigned long addr)
{
  for (int i = 0; i < 18; i++) {
    digitalWrite(AX_1[i], bitRead(addr, i));
  }
}

void setAddrPinsOut()
{
  for (int i = 0; i < 18; i++)
  {
    pinMode(AX_1[i], OUTPUT);
    digitalWrite(AX_1[i], LOW);
  }
}

void setDigitalOut()
{
  for (int i = RD0; i <= RD7; i++)
    pinMode(i, OUTPUT);
}

void setDigitalIn()
{
  for (int i = RD0; i <= RD7; i++) {
    pinMode(i, INPUT);
  }
}

void setCtrlPins()
{
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  digitalWrite(WE, HIGH);
  digitalWrite(OE, HIGH);
}

The next problem is i don't know if i wired the Inputs of the Chip correctly...
It's RESET Pin is always HIGH and BYTE# is always LOW for selecting Byte Mode.
So now theres A-1 Pin free for:

A-1 (LSB address input, byte mode)

What i have to do with this PIN?
I think i messed up something in Code and Hardware, because it has got so many pins.
Link for Datasheet here: Datasheet
The only thing this should do is reading the whole Chip.
Thank you for helping me out. :slight_smile:

Am29F400.PNG

Am29F400.PNG

You are correct there are lots of pins, that is why I am asking for a schematic, not a frizzy thing. All it takes is one of those to be messed up. The next problem is i don't know if i wired the Inputs of the Chip correctly...
It's RESET Pin is always HIGH and BYTE# is always LOW for selecting Byte Mode. This could be part of the problem, not sure.

I solved the problem. It was quite easy. First i thought 4 Megabit = 4Megabyte of data.
So i read 4194304 byte and got random Stuff, logical.
And in BYTE Mode you need 19 Address Lines for 512k x 8-Bit, the LSB is A-1.
This calculation switched on the light above my head :smiley:
2^(number of address lines + 1 (Byte Mode))-1
= (2^19)-1 = 524.287 Addresses.
So our 19 Address Lines are from A17 as MSB to A-1 as LSB.
Then you can read the Parallel EEPROM/Flash and all is fine.
Hope this Information can help some Makers out.
Stay healthy :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.