Infineon AN304 SPI Guide For F RAM ApplicationNotes v02 00 en
Infineon AN304 SPI Guide For F RAM ApplicationNotes v02 00 en
AN304 provides the functional description, timing, and example code for SPI F-RAMs.
Contents
1 Introduction .................................................................. 1 10 Clocking Modes ........................................................... 8
2 Why Use SPI? ............................................................. 1 11 Half-Duplex Operation ................................................. 8
3 Speed Advantages ...................................................... 2 12 Write Protection ........................................................... 9
4 The SPI Bus ................................................................ 2 13 Power Cycling ........................................................... 10
5 System Hookup ........................................................... 3 14 Summary ................................................................... 10
6 Standalone SPI F-RAM Products ................................ 4 15 Related Application Notes ......................................... 10
7 READ/WRITE Transactions......................................... 5 A Pseudo Code Examples (1-Byte Address,
7.1 Memory Reads .................................................... 5 4-Kbit Devices) .......................................................... 11
7.2 Memory Writes .................................................... 5 B Pseudo Code Examples (2-Byte Address,
7.3 Status Register Write .......................................... 6 16-Kbit Through 512-Kbit Devices) ........................... 12
7.4 Status Register Read .......................................... 6 C Pseudo Code Examples (3-Byte Address,
1-Mbit Through 4-Mbit Devices) ................................ 13
8 SPI F-RAM Addressing ............................................... 6
Document History............................................................ 14
9 Placing a Higher-Density F-RAM Device in a
Low-Density Socket ..................................................... 7 Worldwide Sales and Design Support ............................. 15
1 Introduction
The FM25xxx F-RAM product family employs an industry-standard 4-wire SPI interface. They are high-speed (up to
40 MHz), low-power, nonvolatile memory devices. SPI F-RAM densities start from 4 Kbit and extend up to 4 Mbit.
This application note reviews the functional and timing aspects of these devices.
Controller SCK
with SPI SPI
Port SI F-RAM
SO
3 Speed Advantages
F-RAM memory technology enables large data blocks to be written much faster than EEPROM or flash equivalents.
Unlike EEPROM or flash, F-RAM devices do not use a page buffer. F-RAM writes each data byte immediately
following the eighth bit in each byte received. The combination of no-write delays and high clock speed makes the F-
RAM a compelling choice for any application that needs to write a lot of data quickly. Designers have complete
freedom over how many bytes to write to the SPI F-RAM. When a byte or two is written in random locations in an F-
RAM, the write cycle time is approximately 1 µs, whereas an EEPROM or flash imposes its 5 ms to 10 ms write cycle.
In addition, designers do not have to worry about page buffer sizes that change when the system grows to the next
memory density.
Figure 2 provides a chart that compares the time required to write a 256-Kbit array in F-RAM and EEPROM. Even for
an EEPROM with a 64-byte page buffer, the F-RAM device is orders of magnitude faster at the same clock rate. This
is especially significant on a production line where there is a limited time to program the system settings.
Figure 2. Write Time to Fill a 256-Kbit SPI Memory Array
Note that the time taken to write a 256-Kbit EEPROM memory is not significantly improved by increasing the clock
frequency from 5 MHz to 20 MHz. The long write delay needed for each page-write dominates. For a 20-MHz F-RAM
memory, the entire 32-Kbyte array can be written in just 13 ms, which is a small value and does not appear in the
chart provided in Figure 2.
1. Some SPI devices may use 1-byte or 2-byte addressing depending on the density. Refer to Table 2.
2. For 4-Kbit devices, bit 3 of the Write and Read op-codes correspond to upper address bit (A8).
3. All SPI devices may not support this command.
5 System Hookup
Multiple devices may be used as long as the controller has extra pins to drive a chip-select to each F-RAM device.
Figure 3 shows the system configuration for two F-RAM devices interfaced to the standard SPI port of a
microcontroller.
Figure 3. System Configuration for Two F-RAM Devices
For a microcontroller that has no dedicated SPI bus, a general purpose port may be used as shown in Figure 4. A bit-
banging code drives this interface.
3V 5V
FM25CL64B
FM25C160B
FM25W256
FM25V20A
FM25L04B
FM25L16B
FM25040B
FM25640B
FM25H20
FM25V40
FM25V01
FM25V02
FM25V05
FM25V10
FM25V20
Number of
9 11 13 14 15 16 17 18 18 19 9 11 13 15
address bits
Number of
address 1 2 2 2 2 2 3 3 3 3 1 2 2 2
bytes
Operating 2.7- 2.7- 2.7- 2.0- 2.0- 2.0- 2.0- 2.0- 2.7- 2.0- 4.5- 4.5- 4.5- 2.7-
Voltage 3.6 V 3.6 V 3.65 V 3.6 V 3.6 V 3.6 V 3.6 V 3.6 V 3.6 V 3.6 V 5.5 V 5.5 V 5.5 V 5.5 V
Max. Clock
20 MHz 20 MHz 20 MHz 40 MHz 40 MHz 40 MHz 40 MHz 40 MHz 40 MHz 40 MHz 20 MHz 20 MHz 20 MHz 20 MHz
Freq.
Supported
Clock 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3 0, 3
Modes
Sleep Mode
Unique S/N
Device ID
Wide Wide Wide
Package SOIC8 SOIC8 SOIC8
SOIC8 SOIC8 SOIC8 SOIC8
DFN8 DFN8 DFN8 SOIC8 DFN8 SOIC8 SOIC8 DFN8[ DFN8[ DFN8[ SOIC8 SOIC8 SOIC8 SOIC8
(4x4.5) (4x4.5) (4x4.5) (4x4.5) 1 ]
1 ]
1 ]
Note:
1. 5 x 6 mm DFN8 conform to SOIC8 footprint.
7 READ/WRITE Transactions
The SPI interface is synchronous to a clock that is driven by the controller. All the F-RAM SPI devices will register
data input on the rising edge of SCK and drive the data back to the controller on the falling edge of SCK. To comply
with this timing, controllers generally drive signals to the memory on the falling edge of SCK so that the signals have
time to propagate and satisfy the setup timing specifications of the memory device.
SCK
SO Data Out
SCK
SO
Writing the Status Register allows the user to write-protect memory blocks and enable the pin. There are two
block-protect bits, BP1 and BP0. They provide upper quarter, upper half, or entire array protection against writes. The
BP0, BP1, and WPEN bits are highlighted yellow to indicate that they are nonvolatile, retaining their written values
through power cycling events. WPEN enables or disables the external pin. Software may be used to override the
pin from system tampering. WEL is a read-only bit that simply tells the user if the Write Enable Latch has been
set, which allows writes to either the Status Register or the memory.
A complete status register write transaction is shown in Figure 7.
Figure 7. Write Status Register Timing
SCK
SO
SCK
SI RDSR op-code
SO data-out
FM25040B 0 0 0 0 A8 op op op A7 A6 A5 A4 A3 A2 A1 A0
FM25L04B
FM25C160B 0 0 0 0 0 op op op - - - - - A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
FM25L16B
FM25H20
FM25V20 0 0 0 0 0 op op op - - - - - - A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
FM25V20A
FM25V40 0 0 0 0 0 op op op - - - - - A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
10 Clocking Modes
The FM25xxx device families support two of the four SPI standard clocking modes: Mode 0 and Mode 3. Note that
independent of the mode, all F-RAM parts clock data into the device on the rising SCK edge and clock data out on
the falling edge of SCK. The difference between Modes 0 and 3 is simply whether SCK starts LOW or HIGH when
is asserted LOW. The different SPI Modes are listed in Table 3.
Table 3. SPI Modes
Mode Mode Mode Mode
0 1 2 3
SCK Starts … LOW LOW HIGH HIGH
SI Data-In Latched
on …
SO Data-Out Driven
from …
11 Half-Duplex Operation
To reduce the pin count on an SPI interface, the data lines can be tied together to create a common data I/O line.
This 3-wire interface is I’s minimum pin count configuration as shown in Figure 12. The controller must now ensure
that the SIO line is hi-Z during read cycles. Otherwise, bus contention will occur. A secondary issue is that because
the data bus is now half-duplex, this potentially reduces the data bandwidth.
Figure 12. True 3-Wire SPI Interface
CS CS
SI
Regardless of the timing mode (0 or 3), all SPI F-RAMs latch data-in on the rising edge of SCK and drive data-out on
the falling edge of the SCK. An SPI read transaction is shown in Figure 13.
12 Write Protection
SPI F-RAM devices can be write-protected using the hardware pin or by programming the Status Register bits.
The Status Register itself may be protected in addition to the F-RAM memory array. The Status Register contains
nonvolatile block-protect bits BP (1:0) to disable writes to portions of the memory array. BP0, BP1, and WPEN bits
are highlighted yellow in Table 5 to indicate that they are nonvolatile and the settings will survive power cycling.
WPEN enables the hardware pin. Bit location 0 is reserved as a R bit for compatibility with EEPROM and
serial Flash. This bit is used in these devices so that the user can determine whether or not the memory is ready for
another command by reading the Status Register. The R bit is internally hardwired LOW in all SPI F-RAM devices
because the chip is always ready (zero delay) after a write cycle.
Table 4: Status Register and Block Protect Settings
A write-protection table is provided in Table 5, which covers all the cases for write-protecting the Status Register and
the F-RAM array. When WEL = 0, all the writes to the F-RAM array and status register are blocked.
Table 5. Write Protection
13 Power Cycling
An F-RAM device is a high-speed nonvolatile memory and power glitches occurring during either a read or write
sequence may incorrectly overwrite (corrupt) array data. For example, the device can inadvertently write data at mid-
level power supply levels when chip-select is active (LOW). The SPI F-RAM datasheets specify (recommend) that the
device is powered down with chip-select inactive (HIGH).
SPI F-RAM devices have no power management circuits other than a simple internal power-on reset circuit. Ensure
that VDD is within the datasheet tolerances to prevent incorrect operation. It is recommended that the VDD power
supply voltage ramp up and ramp down in a well-controlled manner. Switch-mode power supplies are notorious for
uncontrolled outputs as they power-up or power-down.
The system designer should be aware of chip-enable and VDD states during power cycles. For more details on data
protection, refer to “AN302 - F-RAM SPI Read & Write Internal Operation and Data Protection”.
14 Summary
The application note covers the functional features, timing, and example code for different F-RAM SPI parts.
In every case below, the parentheses designate the pin going LOW “(“ and HIGH “)”.
/****** Memory Read (multiple bytes from starting location 01FCh) *******/
READ (0x0B, // 0x03 is READ opcode
0xFC, // starting address
0x55, // 0x55 is data read from location 01FCh
0xAA, // 0xAA is data read from location 01FDh
0x55, // 0x55 is data read from location 01FEh
0xAA) // 0xAA is data read from location 01FFh
/****** Write Status Register (write protect upper half of memory) *******/
WREN (0x06) // Sets WEL bit. WREN must precede WRSR opcode.
WRSR (0x01, // 0x01 is WRSR opcode
0xF8) // 0xF8 sets the BP1 bit which protects the upper
// half of the memory array. The upper nibble
// set to “F” attempts to write the upper bits
// to 1.
NOTE: Text in BLUE indicates data being sent by the controller. Text in RED indicates data being received by the controller.
/****** Memory Read (multiple bytes from starting location 07FCh) *******/
READ (0x03, // 0x03 is READ opcode
0x07, // starting address MSB
0xFC, // starting address LSB
0x55, // 0x55 is data read from location 07FCh
0xAA, // 0xAA is data read from location 07FDh
0x55, // 0x55 is data read from location 07FEh
0xAA) // 0xAA is data read from location 07FFh
/****** Write Status Register (write protect upper half of memory) *******/
WREN (0x06) // Sets WEL bit. WREN must precede WRSR opcode.
WRSR (0x01, // 0x01 is WRSR opcode
0x08) // 0x08 sets the BP1 bit which protects the upper
// half of the memory array.
/****** Read Status Register *******/
RDSR (0x05, // 0x05 is RDSR opcode
0x88) // 0x88 tells us that the BP1 bit is set and that
// the upper half of the memory array is protected.
// The WPEN bit is also set which works with
// the pin to protect the Status Register.
NOTE: Text in BLUE indicates data being sent by the controller. Text in RED indicates data being received by the controller.
In every case below, the parentheses designate the pin going LOW“(“ and HIGH“)”.
/****** Memory Read (multiple bytes from starting location 1B7FCh) *******/
READ (0x03, // 0x03 is READ opcode
0x01, // starting address MSB
0xB7, // starting address 2nd byte
0xFC, // starting address LSB
0x55, // 0x55 is data read from location 1B7FCh
0xAA, // 0xAA is data read from location 1B7FDh
0x55, // 0x55 is data read from location 1B7FEh
0xAA) // 0xAA is data read from location 1B7FFh
/****** Write Status Register (write protect upper half of memory) *******/
WREN (0x06) // Sets WEL bit. WREN must precede WRSR opcode.
WRSR (0x01, // 0x01 is WRSR opcode
0x08) // 0x08 sets the BP1 bit which protects the upper
// half of the memory array.
Document History
Document Title: AN304 - SPI Guide for F-RAM™
Document Number: 001-87196
PSoC cypress.com/psoc
Power Management ICs cypress.com/pmic
Touch Sensing cypress.com/touch
USB Controllers cypress.com/usb
Wireless Connectivity cypress.com/wireless
All other trademarks or registered trademarks referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
© Cypress Semiconductor Corporation, 2013-2017. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including
pansion LL (“ ypress”). This document, including any software or firmware included or referenced in this document (“ oftware”), is owned by
Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such
laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other
intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with
Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to
sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for
use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end
users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of
ypress’s patents that are infringed by the oftware (as provided by ypress, unmodified) to make, use, distribute, and import the Software solely for
use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD
TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to
make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or
circuit described in this document. Any information provided in this document, including any sample design information or programming code, is
provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and
safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as
critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or
systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances
management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A
critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or
system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim,
damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and
against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, WICED, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are
trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit
cypress.com. Other names and brands may be claimed as property of their respective owners.