arduino-dataflash icon indicating copy to clipboard operation
arduino-dataflash copied to clipboard

AT45DB041D interfacing with arduino Uno

Open tshivamiitk7 opened this issue 7 years ago • 9 comments

Hi, i am trying to interfacing AT45DB041D with arduino uno. I am trying to upload pagetest code from your library, but i am unable to get any result on serial monitor i am getting 0 value for all outputs.

tshivamiitk7 avatar Jun 07 '18 10:06 tshivamiitk7

  • Did you power the dataflash with 3.3V ?
  • Did you check that the pin values for SPI (SS, CS, MISO, MOSI, etc...) are correct ?
  • In pagetest if you remove the content of the loop function, did you get the status register and chip info right ?

BlockoS avatar Jun 08 '18 07:06 BlockoS

Hi, Thanks for your reply, and yes yes i powered the dataflash with 3.3V. The pin values for SPI are as below: Dataflash Arduino Uno Vcc -- 3.3 V Gnd -- Gnd MISO -- Pin 11 MOSI -- Pin 12 SCK -- Pin 13 CS -- Pin 10 In pagetest if i am removing the content of loop function, still i am not getting the right value. I am attaching a snapshot of my output function. capture @BlockoS

tshivamiitk7 avatar Jun 08 '18 08:06 tshivamiitk7

:man_facepalming: doh... I just noticed this in pagetest source code:

/* Initialize dataflash */
  dataflash.setup(5,6,7);

This means that CS is on pin 5. Ok so.. to make it work with your configuration just do:

dataflash.setup(10);

BlockoS avatar Jun 08 '18 08:06 BlockoS

Hi, I have checked the SPI pin connections again and now i am getting the output as attached in the picture below: Can you give me some explaination of the code or any relevant link where i can understand what your code is doing. Also provide me some guidance on my next goal. My task is to acquire the data from microcontroller's ADC and store it in the memory and read it from the memory using commands and USB. capture2

tshivamiitk7 avatar Jun 08 '18 08:06 tshivamiitk7

Hi, i have done that already in dataflash.setup(10,6,7). I guess there was a problem with my MISO & MOSI connections. What are the functions of pin 6&7.

tshivamiitk7 avatar Jun 08 '18 08:06 tshivamiitk7

Ok. Normally you should get "@ write test 0" etc.. but it seems that the behaviour of Serial.print has changed since I wrote this example. You may replace it with Serial.write.

Anyway, this example writes a string starting at offset 0 of the buffer 1. Then the content of the buffer is transferred to a page (the page index is incremented at each loop). Afterwards when all the pages have been used, the content of these pages are read using alternatively pageToBuffer and bufferRead (the content the page is transferred to one of the buffer then this buffer is set to be read) or pageRead where the is directly read (leaving the content of the buffer untouched).

BlockoS avatar Jun 08 '18 09:06 BlockoS

Thanks and also please let me know the changes i have to make in your code for my custom application. Is it possible to do it using your library.

tshivamiitk7 avatar Jun 08 '18 09:06 tshivamiitk7

Here's an idea, each time you read a value from the ADC, you store it to in one of the Dataflash buffer. When this buffer is full (or when you receive a shutdown command) you write this buffer to a page. Note that if you turn off your device the content of the Dataflash buffer will be lost.

At this point the way the data is organized is up to you.

About data read, it depends on the command. If it's "send me all the data" you can loop through all the pages and directly send the data.

BlockoS avatar Jun 08 '18 10:06 BlockoS

Ok thank you so much, your idea seems great. Further before the above task, i want to write 1000 numbers in a sector as a unit and then read them through a microcontroller. Please tell what should be my approach.

tshivamiitk7 avatar Jun 08 '18 13:06 tshivamiitk7