Pages

Sunday, May 12, 2013

RPi SPI EEPROM read write bottle neck problem notes


I read the 25LC256 datasheet again and also another application note AN1193, which clarify my confusion and misunderstanding about page write.   It appears that Microchip refers to byte write as writing one byte, and page write as writing more than one bye but less than a page.

It also recommends to use 0.1uF to filter noise at Vcc.

Another thing is that commands can be used as a sequence, as the example below.

Write Enable (WREN) + Write STATUS Register (WRSR) + WRITE (#NOPROT = 00).

And the bottle neck is the write timing of about 5 mS, or 1 / (5 * 0.001) = 200 times per second, which is really slow.  So I think I need to consider RPi using a read/write buffer in the 512MB RAM to speed things up.


Microchip AN1193 Using C to Interface 8051 MCUs with SPI Serial EEPROMs - Alexandru Valeanu , Microchip 2008

http://ww1.microchip.com/downloads/en/AppNotes/01193A.pdf


CIRCUIT

...

Note 1: A decoupling capacitor (typically 0.1 µF) should be used to filter noise on VCC. 

Note 2: WP and HOLD pins should have pull-up resistors (2 kΩ to 10 kΩ).

...


INITIALIZATION

The structure of the initialization operation is as follows:

Write Enable (WREN) + Write STATUS Register (WRSR) + WRITE (#NOPROT = 00). 


WRITE ENABLE

Before a write operation to the serial EEPROM can occur, the MCU must set the Write Enable Latch (WEL). This is done by issuing a WREN command.

The MCU clears the WEL bit by issuing a Write Disable command (WRDI). The WEL bit is also automatically reset if the serial EEPROM is powered down or if a write cycle is completed.


BYTE WRITE

The byte write operation consists of the following components: the WRITE command followed by the word address and data byte. The word address for the 25XX256 is a 16-bit value, so two bytes must be transmitted for the entire word address, with the Most Significant Byte sent first. Note that the WREN instruction is not illustrated in this section but is still required to initiate the operation.


BYTE READ

The byte read operation can be used to read data from the serial EEPROM. The MCU transmits the command byte followed by the word address bytes to the serial EEPROM.


PAGE WRITE

Page write operations provide a technique for increasing throughput when writing large blocks of data. The 25XX256 serial EEPROM features a 64-byte page. By using the page write feature, up to 1 full page of data can be written consecutively.

It is important to point out that page write operations are limited to writing bytes within a single physical page, regardless of the number of bytes actually being written. Physical page boundaries start at addresses that are integer multiples of the page size, and end at addresses that are [integer multiples of the page size minus 1. Attempts to write across a page boundary result in the data being wrapped back to the beginning of the current page, thus overwriting any data previously stored there.

The page write operation is very similar to the byte write operation. The serial EEPROM automatically increments the internal Address Pointer to the next higher address with receipt of each byte.

PAGE READ

Page read operations read a complete string, starting with the specified address.

In contrast to page write  operations described on the previous page, there is no maximum length for page read. After 64 Kbytes have been read, the internal address counter rolls over to the beginning of the array.


BYTE WRITE VERSUS PAGE WRITE

At first glance, the page write method appears superior to the byte write method: it’s simpler and faster. However, a careful analysis shows that the byte write method has a major advantage over page write owing to the roll-over phenomenon (see Note).

As a consequence of the roll-over phenomenon, applications that write long strings to the SPI serial EEPROM risk overlapping the page boundary in the middle of a string. In such instances, the firmware should use byte write to avoid this condition. The disadvantage of doing this is the slower speed involved in writing the entire string: every byte write cycle time is approximately 5 ms.


The following summarizes the differences between the byte write and page write methods.

Byte Write

• Is slower – It needs a 5 ms write cycle time for each byte.

• Is more general – It may write a string of any length.

Page Write

• Is faster – It needs only one write cycle time for the whole page.

• Care must be taken to observe page boundaries during page writes.


CONCLUSION

This application note offers designers a set of firmware routines to access SPI serial EEPROMs. The code demonstrates byte and page operations.

All routines were written in C for an 8051-based MCU.

.END


No comments:

Post a Comment