Introduction
Programming SPI memory devices is a common use case for the Promira™ Serial Platform with SPI Active Level 1 Application. There are several ways to do this with the Promira™ Serial Platform, including using Control Center Serial, Flash Center, or the Promira API. This article focuses on how to take the information in a flash datasheet and execute the commands in Control Center Serial. 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 Promira platform erases the M25P32, writes and reads the Status Register, and writes and reads three bytes (0x0A 0x0B 0x0C) from address 0x08. Here the Promira platform is the SPI master and the M25P32 in the SPI Flash Demo Board is the SPI slave. The Promira platform is connected to the M25P32 in the SPI Flash Demo Board through the 34-10 I2C/SPI cable. The Promira platform supplies 3.3V SPI signals and 5V VDD signal to the SPI Flash Demo Board. For additional information take a look at SPI Flash Demo Board user manual.
M25P32 Details
The article uses multiple M25P32 instructions, which are described below. Figure 1 shows the M25P32 Instructions List. See the M25P32 datasheet for additional details.
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
Writing and Reading Guidelines
- Connect the Promira platform USB connector to the PC USB connector.
- Follow the instructions in Section 3.2 - Connectivity of the Promira platform user manual to configure the Ethernet over USB interface.
- Download and unzip the latest version of Control Center Serial. (?)
- Connect the Promira platform I2C/SPI connector to the SPI Flash Demo Board through 34-10 cable.
- Launch Control Center Serial. (?)
- Connect Control Center Serial to the Promira platform. (?)
- Click Adapter, and choose Connect.
- Select the Promira platform.
- Click OK to connect to the Promira platform.
- Click Adapter, and choose I2C+SPI.
- Click Adapter, disable I2C Pulls-Ups, enable Target Power (Pin 4,6), disable IO Power (Pin 22,24), and configure Level Shift to 3.3V. (?)
- Configure the adapter as an SPI Master using the SPI Control panel. (?)
- Click on the SPI Master tab.
- Configure the Polarity to Rising/Falling, Phase to Sample/Setup, and Bitrate to 12500KHz, (?)
- Configure the Bit Order to MSB, and SS Polarity to SS Active Low.
- Erase the entire memory device (?).
- Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
- Enter C7 in the MOSI Message > Click Send. (This Bulk Erase Instruction erases the memory.)
- Write and read memory Status Register.
- Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
- Enter 01 00 in the MOSI Message > Click Send. (This Write Status Instruction writes 00 to the memory Status register.)
- Enter 05 00 in the MOSI Message > Click Send. (This Read Status Instruction reads 00 or 03 from the memory Status register.)
- Write and read memory.
- Enter 06 in the MOSI Message > Click Send. (This Write Enable instruction sets the Write Enable Latch bit)
- 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.)
- 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 7: Promira Platform Writes and Reads M25P32 Memory
Notes
For additional information, take a look at the Promira platform user manual, Control Center Serial user manual, and SPI Flash Demo Board user manual.