Writing and Reading from SPI Flash Using the Cheetah Adapter and Cheetah GUI Software - Part 1

Last week, we featured a two-part blog feature on how to program a single sector of an SPI flash with the Cheetah adapter and the Flash Center Software. This week, we want to demonstrate the versatility and fast functions of the Cheetah SPI Host Adapter with the Cheetah GUI Software. This week's two-part Support Question of the Week series will focus on how to write and read from an SPI flash device using the Cheetah adapter and the Cheetah GUI Software.

This two-part blog article is also available in our Total Phase Knowledge Base. The Knowledge Base consists of popular FAQ's and technical articles provided by our very own support team.

Programming and reading SPI memory devices is a common use case for the Cheetah Adapter. There are several ways to do this with the Cheetah adapter, including using Cheetah GUI Software, Flash Center Software, or the Cheetah Software API. This article focuses on how to take the information in a flash datasheet and execute the commands in Cheetah GUI Software. Although the following describes the SPI Flash M25P32 found on the SPI Flash Demo Board, similar steps can be used for other devices. The goal of this article is to demonstrate how to write several bytes to a specific address and then read back those bytes.

Overview

In this article the Cheetah adapter erases the M25P32, writes and reads the Status Register, writes and reads three bytes (0x0A 0x0B 0x0C) from address 0x08. Here the Cheetah adapter is the SPI master and the SPI flash on the demo board is the SPI slave. The article uses multiple M25P32 instructions, which are described below.

Figure 1: M25P32 Instructions List

The M25P32 Write Enable instruction (0x06) sets the Write Enable Latch bit. The Write Enable Latch bit must be set prior to every Page Program, Sector Erase, Bulk Erase, and Write Status Register instruction.

Figure 2: M25P32 Write Enable Instruction

The M25P32 Write Status Register instruction (0x01) allows new values to be written to the Status Register. This instruction includes the instruction opcode, and the required status register value. The Status Register includes the following bits: Write In Progress (WIP), Write Enable Latch (WEL), Block Protect (BP2, BP1, BP0), and Status Register Write Disable (SRWD).

Figure 3: MP25P32 Write Status Register instruction

The M25P32 Read Status Register instruction (0x05) allows the Status Register to be read. This instruction includes the instruction opcode. Then the Status Register content is shifted out.

Figure 4: M25P32 Read Status Register Instruction

The M25P32 Page Program instruction (0x02) is used for programing the memory bytes. This instruction includes the instruction code, three address bytes, and at least one data byte.

Figure 5: M25P32 Page Program Instruction

The M25P32 Read Data Bytes instruction (0x03) is used for reading the memory bytes. This instruction includes the instruction code, and three address bytes. Then the memory contents, at that address, is shifted out. For additional information about the SPI Flash M25P32 take a look at the M25P32 datasheet.

Figure 6: M25P32 Read Data Bytes Instruction

Part 2 of this blog feature will be posted soon! The second part will focus on how to read and write memory to the flash device.

Any questions? Email us at sales@totalphase.com or support@totalphase.com.

Leave a Reply