I2C SPI USB CAN eSPI Cable Testing View All Videos Quick Start Guides Software Downloads App Notes White Papers User Manuals Knowledge Base Sales Support About Us
Products Blog Sales Support Contact Search
Writing and Reading from SPI Flash Using Aardvark Adapter and Control Center
Writing and Reading from SPI Flash Using Aardvark Adapter and Control Center

Introduction

Programming and reading SPI memory devices is a common use case for the Aardvark Adapter. There are several ways to do this with the Aardvark adapter, including using Control Center, Flash Center, or the Aardvark API. This article focuses on how to take the information in a flash datasheet and execute the commands in Control Center. 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 Aardvark adapter erases the M25P32, writes and reads the Status Register, writes and reads three bytes (0x0A 0x0B 0x0C) from address 0x08. Here the Aardvark 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

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

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

M25P32 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

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

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

M25P32 Read Data Bytes Instruction

Memory Programing and Reading Guidelines

    1. Download and run the latest version of the Total Phase USB Drivers Installer.
    2. Download and unzip the latest version of Control Center. (?)
    3. Connect the Aardvark adapter to the PC via the USB connector.
    4. Connect the Aardvark adapter to the SPI flash demo board via the I2C/SPI connector. (?)
    5. Launch Control Center. (?)
    6. Connect the Aardvark adapter to Control Center. (?)
      1. Click Aardvark -> Connect.
      2. Select the Aardvark adapter.
      3. Click OK to connect to the adapter.
    7. Confugure the Polarity to Rising/Falling, Phase to Sample/Setup, Bitrate to 4000KHz, Bit Order to MSB, and SS Polarity to SS Active Low. (?)
    8. Enable Target Power. (?)
    9. Erase the entire memory device (?).
      1. Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
      2. Enter C7 in the MOSI Message > Click Send. (This Bulk Erase Instruction erases the memory.)

Figure 7: Aardvark Adapter Erases M25P32

    1. Write and read memory Status Register.
      1. Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
      2. Enter 01 00 in the MOSI Message > Click Send. (This Write Status Instruction writes 00 to the memory Status register.)
      3. Enter 05 00 in the MOSI Message > Click Send. (This Read Status Instruction reads 00 from the memory Status register.)

Figure 8: Aardvark Adapter Writes and Reads M25P32 Status Register

    1. Write and read memory.
      1. Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
      2. Enter 02 00 00 08 0A 0B 0C in the MOSI Message > Click Send. (This Page Program Instruction writes 0x0A 0x0B 0x0C to memory address 0x08.)
      3. Enter 03 00 00 08 00 00 00 in the MOSI Message > Click Send. (This Read Data Bytes Instruction reads 0x0A 0x0B 0x0C from the memory address 0x08.)

Figure 9: Aardvark Adapter Writes and Reads M25P32 Memory

 

Notes

For additional information, take a look at the Aardvark adapter user manual, Control Center manual and High Speed SPI Flash Demo Board User Manual.