BlockoS / arduino-dataflash

Support for Atmel Dataflash for the Arduino
http://blockos.github.com/arduino-dataflash
23 stars 14 forks source link

AT45DB041D interfacing with arduino Uno #24

Open tshivamiitk7 opened 6 years ago

tshivamiitk7 commented 6 years ago

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.

BlockoS commented 6 years ago
tshivamiitk7 commented 6 years ago

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

BlockoS commented 6 years ago

: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);
tshivamiitk7 commented 6 years ago

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 commented 6 years ago

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.

BlockoS commented 6 years ago

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).

tshivamiitk7 commented 6 years ago

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.

BlockoS commented 6 years ago

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.

tshivamiitk7 commented 6 years ago

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.