Programming a Single Sector of an SPI Flash Using the Cheetah Adapter and Flash Center - Part 1

The Cheetah SPI Host Adapter is popular for its fast SPI programming capabilities. In this week's Support Question of the Week, we will feature a two-part series focusing on how to program a single sector of an SPI flash device using the Cheetah adapter with the Flash Center Software.

This two-part 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.

Overview

Using the Aardvark I2C/SPI Host Adapter or the Cheetah SPI Host Adapter with the Flash Center software makes it extremely easy to program EEPROM and flash devices. With one click the user can erase, program, and verify an entire device. But what if you only need to program a single sector of a flash memory? This article explains how to use Flash Center to modify a single sector of the device, while not affecting the other sectors.

It's first helpful to understand the different programming options provided by Flash Center. Specifically, there are three programming modes: Program + Verify, Program, and Program (No Erase).

  • Program + Verify - Writes data to one or more attached memory devices and then reads back the data to verify it for correctness. If the device is an SPI Flash, an erase cycle will be performed first. The erase will cover only those sectors which will be written. Note that it is possible to erase more data than is written if a write ends in the middle of a sector. A warning will be logged if this is the case. Also, if the data to be written is large enough to require the entire device to be erase, and the memory device has an “erase all” instruction, the software will use the “erase all” instruction.
  • Program - Writes data to the device, but does not perform the verification step. If the device is an SPI Flash, an erase cycle will be performed first, with the same caveats as Program + Verify.
  • Program (No Erase) - A special mode for SPI Flash devices. It writes data to the device, but does not perform an erase cycle. This is useful if multiple memory images are to be programmed to the device. Use FF as the pad value when loading each memory image to avoid corrupting previously written data. Because the device may have been programmed prior to this operation, it does not perform the verification step.

For additional information about the Flash Center program modes, take a look at the Flash Center manual.

To program a single sector with Flash Center, we will take advantage of the following properties of flash devices:

  • Programming a flash device can only change the value of a bit from 1 to 0 and has no affect when attempting to change a bit from 0 to 1.
  • Erasing a flash device changes all the bits in a sector (or the entire device) to 1.

By manually erasing specific sectors along with using the Program (No Erase) mode, data can be written to any sector of a flash device.

M25P32 Details

The 32 Mbit (4M bytes) SPI Flash M25P32 found on the SPI Flash Demo Board has 64 sectors. Each sector has 256 pages or 65,536 (64K, 0x10000) bytes. Each page has 256 bytes. Therefore, the memory has 16,384 pages or 4,194,304 (0x400000) bytes. The whole memory can be erased using the Bulk Erase instruction, or a sector at a time, using the Sector Erase instruction. For additional information about the SPI Flash M25P32 take a look at the M25P32 datasheet.

Part 2 of this special feature will be posted soon! The second installment will focus on how to program data to the first sector, and then program data to the second sector without overwriting data in the first sector.

Questions? Feel free to email us at sales@totalphase.com or support@totalphase.com.

Leave a Reply