This is a library for dataflash memory. Dataflash is essentially external FLASH memory on a chip; this library lets you make the Arudino talk to that external memory chip and store values or data there, for applications like datalogging.
The code is from the atmel butterfly, ported to gcc by Martin Thomas. I changed it to c++ so it can be used as a library for arduino. You can download the library here. Put the dataflash directory in your arduino-0008/lib/targets/libraries/ directory and (re)start arduino. You can ask your question in this topic in the forum.
I have tested the library with AT45DB041B. Others should work but I don't have them available. This chip is not available in a DIL package so you have solder wires to it or put it on a small pcb, like this. Connect it like this:
dataflash arduino pin 1 -- pin 11 pin 2 -- pin 13 pin 3 -- pin 8 pin 4 -- pin 10 pin 5 -- pin 7 pin 6 -- V (2.5-3.6V) pin 7 -- ground pin 8 -- pin 12
It is 5 volt tolerant but it needs a lower voltage. I haven't tried to power it with 5 volt. I used a zetex voltage regulator. Very easy, doesn't need extra components. If you have an Arduino BT you can also get 3.3 v from there. The other connections for SPI are directly connected. This should be possible according to the manual and so far it works. I have attached a small example with some comments. Copy the dataflash_intro from the directory from the zip file to your arduino sketch directory and it should work. The code in the library is commented but for convenience I copied it below.
Function name : Page_To_Buffer Returns : None Parameters : BufferNo -> Decides usage of either buffer 1 or 2 PageAdr -> Address of page to be transferred to buffer Purpose : Transfers a page from flash to Dataflash SRAM buffer Function name : Buffer_Read_Byte Returns : One read byte (any value) Parameters : BufferNo -> Decides usage of either buffer 1 or 2 IntPageAdr -> Internal page address Purpose : Reads one byte from one of the Dataflash internal SRAM buffers Function name : Buffer_Read_Str Returns : None Parameters : BufferNo -> Decides usage of either buffer 1 or 2 IntPageAdr -> Internal page address No_of_bytes -> Number of bytes to be read *BufferPtr -> address of buffer to be used for read bytes Purpose : Reads one or more bytes from one of the Dataflash internal SRAM buffers, and puts read bytes into buffer pointed to by *BufferPtr Function name : Buffer_Write_Enable Returns : None Parameters : IntPageAdr -> Internal page address to start writing from BufferAdr -> Decides usage of either buffer 1 or 2 Purpose : Enables continous write functionality to one of the Dataflash buffers buffers. NOTE : User must ensure that CS goes high to terminate this mode before accessing other Dataflash functionalities Function name : Buffer_Write_Byte Returns : None Parameters : IntPageAdr -> Internal page address to write byte to BufferAdr -> Decides usage of either buffer 1 or 2 Data -> Data byte to be written Purpose : Writes one byte to one of the Dataflash internal SRAM buffers Function name : Buffer_Write_Str Returns : None Parameters : BufferNo -> Decides usage of either buffer 1 or 2 IntPageAdr -> Internal page address No_of_bytes -> Number of bytes to be written *BufferPtr -> address of buffer to be used for copy of bytes from AVR buffer to Dataflash buffer 1 (or 2) Purpose : Copies one or more bytes to one of the Dataflash internal SRAM buffers from AVR SRAM buffer pointed to by *BufferPtr Function name : Buffer_To_Page Returns : None Parameters : BufferAdr -> Decides usage of either buffer 1 or 2 PageAdr -> Address of flash page to be programmed Purpose : Transfers a page from Dataflash SRAM buffer to flash Function name : Cont_Flash_Read_Enable Returns : None Parameters : PageAdr -> Address of flash page where cont.read starts from IntPageAdr -> Internal page address where cont.read starts from Purpose : Initiates a continuous read from a location in the DataFlash Function name : Page_Buffer_Compare Returns : 0 match, 1 if mismatch Parameters : BufferAdr -> Decides usage of either buffer 1 or 2 PageAdr -> Address of flash page to be compared with buffer Purpose : comparte Buffer with Flash-Page Function name : Page_Erase Returns : None Parameters : PageAdr -> Address of flash page to be erased Purpose : Sets all bits in the given page (all bytes are 0xff)