Go Down

Topic: library for Dataflash AT45DB011D? (Read 275 times) previous topic - next topic

perigalacticon

I have a AT45DB011D 1Mb flash storage IC I'd like to use with Arduino applications. I have tried to get it to work with several libraries without success.  Is there anyone that has successfully used Dataflash chips with arduino that could assist me with using a library for the AT45DB011D? 

Most recently I tried the arduino-dataflash library: https://github.com/BlockoS/arduino-dataflash.  The available examples haven't worked correctly so I tried to make my own.

Below is my test sketch and the output I see on the Serial Monitor, the returned data values are not as expected.  Any help to get my AT45DB011D working would be appreciated.

Sketch:
Code: [Select]
// arduino-dataflash example
//
#include <SPI.h>
#include "DataFlash.h"

DataFlash dataflash;
uint8_t page;  // dataflah page #.
uint8_t data;  // value stored in dataflash.
int i, j;  // indices for retrieving data values.

//=============================================================================================================================
void setup()
{
  uint8_t status;
  DataFlash::ID id;
  Serial.begin(115200);

  SPI.begin();
  dataflash.setup(10, 6, 7);
  delay(10);
  dataflash.begin();
  status = dataflash.status();
  dataflash.readID(id);
  Serial.print("Status register :");
  Serial.print(status, BIN);
  Serial.print('\n');

  /* Display manufacturer and device ID */
  Serial.print("Manufacturer ID :\n"); 
  Serial.print(id.manufacturer, HEX);
  Serial.print('\n');

  Serial.print("Device ID (part 1) :\n");
  Serial.print(id.device[0], HEX);
  Serial.print('\n');

  Serial.print("Device ID (part 2)  :\n");
  Serial.print(id.device[1], HEX);
  Serial.print('\n');

  Serial.print("Extended Device Information String Length  :\n");
  Serial.print(id.extendedInfoLength, HEX);
  Serial.print('\n');
}


//=============================================================================================================================
void loop()
{
  dataflash.bufferWrite(1, 0);
  for (data = 0; data < 5; data++)  // send data to buffer:
  {
    SPI.transfer(100);  // send the number "100".
    Serial.print("transfer to buffer, data = ");
    Serial.println(data);
  }

  Serial.print("transfer buffer to flash, page = ");
  Serial.println(page);

  dataflash.bufferToPage(1, page);  //  transfer buffer to dataflash page.

  page++;

  if (page > 4)  // after writing to 5 pages read back the data from flash:
  {
    for (i = 0; i < 5; i++)
    {
      dataflash.pageRead(i, 0);
      Serial.print("page read = ");
      Serial.println(i);
      for (j = 0; j < 10; j++)
      {
        data = SPI.transfer(0xff);
        Serial.print("data address = ");
        Serial.print("\t");       
        Serial.print(j);       
        Serial.print("\t");               
        Serial.print("data value read = ");
        Serial.print("\t");               
        Serial.println(data);
      }

    }
    page = 0;
  }
}
//=============================================================================================================================

Output:
Code: [Select]
Status register :10001101
Manufacturer ID :
1F
Device ID (part 1) :
22
Device ID (part 2)  :
0
Extended Device Information String Length  :
0
transfer to buffer, data = 0
transfer to buffer, data = 1
transfer to buffer, data = 2
transfer to buffer, data = 3
transfer to buffer, data = 4
transfer buffer to flash, page = 0
transfer to buffer, data = 0
transfer to buffer, data = 1
transfer to buffer, data = 2
transfer to buffer, data = 3
transfer to buffer, data = 4
transfer buffer to flash, page = 1
transfer to buffer, data = 0
transfer to buffer, data = 1
transfer to buffer, data = 2
transfer to buffer, data = 3
transfer to buffer, data = 4
transfer buffer to flash, page = 2
transfer to buffer, data = 0
transfer to buffer, data = 1
transfer to buffer, data = 2
transfer to buffer, data = 3
transfer to buffer, data = 4
transfer buffer to flash, page = 3
transfer to buffer, data = 0
transfer to buffer, data = 1
transfer to buffer, data = 2
transfer to buffer, data = 3
transfer to buffer, data = 4
transfer buffer to flash, page = 4
page read = 0
data address = 0 data value read = 200
data address = 1 data value read = 253
data address = 2 data value read = 235
data address = 3 data value read = 255
data address = 4 data value read = 188
data address = 5 data value read = 115
data address = 6 data value read = 125
data address = 7 data value read = 167
data address = 8 data value read = 231
data address = 9 data value read = 247
page read = 1
data address = 0 data value read = 255
data address = 1 data value read = 255
data address = 2 data value read = 255
data address = 3 data value read = 255
data address = 4 data value read = 255
data address = 5 data value read = 255
data address = 6 data value read = 255
data address = 7 data value read = 255
data address = 8 data value read = 255
data address = 9 data value read = 255
page read = 2
data address = 0 data value read = 255
data address = 1 data value read = 255
data address = 2 data value read = 255
data address = 3 data value read = 255
data address = 4 data value read = 255
data address = 5 data value read = 255
data address = 6 data value read = 255
data address = 7 data value read = 255
data address = 8 data value read = 255
data address = 9 data value read = 255
page read = 3
data address = 0 data value read = 255
data address = 1 data value read = 255
data address = 2 data value read = 255
data address = 3 data value read = 255
data address = 4 data value read = 255
data address = 5 data value read = 255
data address = 6 data value read = 255
data address = 7 data value read = 255
data address = 8 data value read = 255
data address = 9 data value read = 255
page read = 4
data address = 0 data value read = 255
data address = 1 data value read = 255
data address = 2 data value read = 255
data address = 3 data value read = 255
data address = 4 data value read = 255
data address = 5 data value read = 255
data address = 6 data value read = 255
data address = 7 data value read = 255
data address = 8 data value read = 255
data address = 9 data value read = 255

perigalacticon

Got this working with the https://github.com/BlockoS/arduino-dataflash library, works great, had to modify it as it didn't support the chip which only has 1x 256/264 SRAM buffer as the chip is a small size.

Go Up