Epiphany

LUFA (Formerly MyUSB) Library, Projects Add comments

A weekend without internet has given me a lot of time to work on the code, which is still shaping up quite nicely.

I had an epiphany while browsing through my Mass Storage demo application code, which seems obvious now that I’ve worked it all out. It also explains what Atmel were trying to achieve with all the dataflash page translation routines they’ve written for their own demo.

Previously, the pages of the dataflash ICs were merged together in a continuous stream by the MyUSB Dataflash API, so that there was a virtual Dataflash of twice the single IC capacity. This way arranged in the following manner:

[Chip 1, Page 0][Chip 1, Page 1][...][Chip 1, Page n][Chip 2, Page 0][Chip 2, Page 1][...][Chip 2, Page n]

That was the most logical system to myself when I first started. Writing to the dataflash was done as follows:

1) Select dataflash IC for the current page address

2) Send buffer write command

3) Write data to buffer

4) Send page write from buffer command

5) Wait while operation completes

However, this was grossly inefficient; for each page, the device has to wait until the page has completed writing before it continues on to the next page. Solving this involves interleaving the dataflash pages, using the LSB of the page address to indicate which chip to use:

[Chip 1, Page 0][Chip 2, Page 0][...][Chip 1, Page n][Chip 2, Page n]

Which means that since each consecutive page address is in a different dataflash IC, the busy-wait loop can be moved to the start of the process, after the chip select. Now the wait only occurs after both dataflash chips have been writing, and the first (still busy) chip has been selected again. This results in a good speed increase for consecutive page writes.

1) Select dataflash IC for the current page address

2) Wait while any oustanding operation complete

3) Send buffer write command

4) Write data to buffer

5) Send page write from buffer command

New are two unfinished demonstration applications; a USB Mass Storage Host demo (which will eventually read out the first logical block of an attached device, and could be expanded with a file system driver to read/write data on an attached disk) and a USB Audio Output Device. I’m hoping to complete the Mass Storage Host demo application in the next few days.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in