0

Reading and writing to flash memory via USB

Posted by Chris on Saturday, October 31, 2009
Re-reading the AT45DB041D Flash memory datasheet, using the chip like an oversized eeprom looks like it could cause us a few problems, namely because of the architecture of the memory. On page 4 of the datasheet, we can see that data needs to be written in 256-byte blocks, or pages as they are called.

Data is stored in an internal buffer before being transferred to/from main storage.
Although this might be useful for us in future, at the minute we're using Flash memory like a mini hard-drive: just somewhere to dump data to be read back at a later date. The use of buffers just adds an extra layer of complexity, so we'd prefer to skip these. Luckily, it is possible to do just this:

A main memory page read allows the user to read data directly from any one of the 2,048 pages in the main memory, bypassing both of the data buffers and leaving the contents of the buffers unchanged.

By sending the appropriate opcode (command to you and me) and a 3-byte memory address, it's possible to set the page number for reading/writing data. Data can be read/written serially from the start of each page. Should more than 256 bytes be written at a time, the chip simply crosses the boundary without delay or error. However, because we now have a bit more RAM to play with on the PIC chip, we're going to try to use our own buffering system in the PIC and transfer entire "pages" of 256-bytes to the Flash memory at a time.

0 Comments

Post a Comment

whos.amung.us

Copyright © 2009 .Nerd Club All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive Supported by Blogger Templates.