CONTENTS

    How to Use the W25Q128JVSIQ Flash Memory in Embedded Projects

    avatar
    danny@gns-ic.com
    ·August 5, 2025
    ·10 min read
    How to Use the W25Q128JVSIQ Flash Memory in Embedded Projects
    Image Source: unsplash

    You can use the W25Q128JVSIQ in many embedded projects by connecting it to your microcontroller, setting up the SPI interface, and sending simple commands to read or write data. This chip works in smartphones, routers, automotive systems, and even industrial controllers, as shown below:

    Application Category

    Typical Devices / Use Cases

    Consumer Electronics

    Smartphones, tablets, laptops (storage, firmware)

    Automotive Electronics

    Infotainment, engine controllers, ADAS

    Industrial Control Systems

    Automation equipment, data logging

    IoT Devices

    Sensor data, configuration storage

    The W25Q128JVSIQ stands out for its fast speeds, low power use, and strong data protection. You get reliable performance in harsh or space-limited environments when you follow best wiring and setup practices.

    Key Takeaways

    • Connect the W25Q128JVSIQ chip to your microcontroller using the correct SPI pins and check the datasheet for pin functions to avoid mistakes.

    • Use a stable 3.3 V power supply with a nearby 0.1 µF capacitor to keep the chip running smoothly and reduce noise.

    • Set your SPI interface to Mode 0, 8-bit data, MSB first, and adjust clock speed based on your wiring quality to ensure reliable communication.

    • Follow the proper command sequences to read, write, and erase data safely, always checking the status register to confirm operations finish.

    • Prevent data loss by spreading write and erase cycles across memory sectors and double-check wiring and SPI settings if you encounter errors.

    W25Q128JVSIQ Setup

    W25Q128JVSIQ Setup
    Image Source: unsplash

    Pinout

    You will find the W25Q128JVSIQ in an 8-pin SOIC package. This small chip fits well on most circuit boards, even when space is tight. The pins have clear functions:

    Pin Number

    Name

    Function

    1

    /CS

    Chip Select

    2

    DO/IO1

    Data Output

    3

    /WP

    Write Protect

    4

    GND

    Ground

    5

    DI/IO0

    Data Input

    6

    CLK

    Serial Clock

    7

    /HOLD

    Hold

    8

    VCC

    Power Supply

    You should always check the datasheet before connecting the pins. This helps you avoid mistakes and keeps your project safe.

    Power

    The W25Q128JVSIQ works best with a supply voltage between 2.7 V and 3.6 V. It draws a maximum of 25 mA during active use. When you do not need it, the chip can enter a power-down mode and use as little as 1 µA. Here is a quick summary:

    Parameter

    Value

    Supply Voltage Min

    2.7 V

    Supply Voltage Max

    3.6 V

    Active Read Current Max

    25 mA

    💡 Tip: Use a stable 3.3 V power supply for most projects. Place a 0.1 µF ceramic capacitor close to the VCC and GND pins. This helps filter out noise and keeps the chip running smoothly.

    Wiring

    You should keep your wiring short and direct. Long wires can pick up noise and cause errors. Connect the chip select, clock, and data lines to your microcontroller’s SPI pins. Make sure to connect the ground and power pins first. If you use the write protect or hold features, pull these pins high with a resistor. For best results, avoid running SPI lines near high-power or noisy circuits.

    🛠️ Note: Double-check all connections before powering up. A wiring mistake can damage the chip or your microcontroller.

    SPI Configuration

    SPI Configuration
    Image Source: pexels

    SPI Settings

    You need to set the SPI interface on your microcontroller to match the requirements of the W25Q128JVSIQ. Using the correct settings helps you avoid communication errors and keeps your data safe. Here are the recommended SPI parameters:

    • SPI Mode: Mode 0 (Clock Polarity CPOL = 0, Clock Phase CPHA = 0)

    • Data width: 8 bits

    • Data transfer order: MSB first

    • Clock speed: about 2.5 Mbits/sec for most setups

    • SPI communication: Full Duplex master mode

    If you use a breadboard, lower the SPI speed to 4 MHz or less. This helps prevent signal problems. On a well-designed PCB, you can use higher speeds, even up to 50 MHz, if your wiring is short and clean.

    Tip: Always check your microcontroller’s datasheet for SPI pin locations and speed limits.

    Initialization

    You must initialize the SPI interface before you can talk to the flash memory. Most platforms, like STM32 and Arduino, offer libraries that make this step easy. For Arduino, you can use the SPIMemory or SerialFlash library. These libraries support the W25Q128JVSIQ and work with many boards, including STM32 and ESP32.

    Here is a simple Arduino example:

    #include <SPI.h>
    #include <SPIMemory.h>
    
    SPIFlash flash(10); // 10 is the CS pin
    
    void setup() {
      Serial.begin(9600);
      flash.begin();
    }
    

    For STM32, you can use the Arduino IDE or STM32CubeIDE. Make sure you select the right SPI port and pins.

    • Use the correct driver library for your platform.

    • Set the SPI mode and speed as shown above.

    • Double-check your pin assignments.

    Chip Select

    The chip select (CS) pin tells the flash memory when to listen. You must set this pin low before sending commands and high when you finish. On Arduino and STM32, you can choose any free digital pin for CS, but you must declare it in your code.

    If you use an ESP32, remember that it has built-in SPI flash. You must set the CS pin for your external flash chip, or you may get conflicts.

    🛡️ Note: Always use the same CS pin in both your wiring and your code. This prevents communication errors.

    W25Q128JVSIQ Operations

    Device ID

    You can check if your flash memory chip is connected and working by reading its device ID. This step helps you confirm that you have the right chip and that your SPI connection works.

    The official SPI command sequence to read the device ID (JEDEC ID) from the W25Q128JVSIQ flash memory involves sending the JEDECID instruction byte (0x9F) over SPI, then reading 3 bytes representing the Manufacturer ID and Device ID. The sequence is:

    • Assert chip select (cs_reset)

    • Send command byte 0x9F (JEDECID)

    • Receive 3 bytes of data

    • Deassert chip select (cs_set)

    When you send the 0x9F command, the chip responds with three bytes. The first byte is the Manufacturer ID, which is always 0xEF for Winbond chips. The next two bytes show the memory type and capacity. For example, if you read 0xEF4018, you know you have a Winbond chip with a specific size and type. This process helps you make sure you are talking to the right device.

    Here is a simple code example in C:

    uint32_t W25_Read_ID(void)
    {
        uint8_t dt[4];
        tx_buf[0] = 0x9F; // JEDEC ID command
        cs_reset();          // Assert CS
        SPI1_Send(tx_buf, 1); // Send command
        SPI1_Recv(dt, 3);    // Read 3 bytes
        cs_set();            // Deassert CS
        return (dt[0] << 16) | (dt[1] << 8) | dt[2];
    }
    

    If you get the expected ID, your wiring and SPI settings are correct.

    Read

    You can read data from the W25Q128JVSIQ using SPI commands. The chip supports fast read speeds, which makes it great for storing and retrieving large amounts of data.

    • The W25Q128JVSIQ supports a maximum read clock frequency of up to 104 MHz in standard SPI mode.

    • Quad SPI mode uses four data lines at once, which makes data transfer much faster.

    • The device achieves high sequential read throughput, so you can access data quickly.

    To read data, you usually send a read command (like 0x03 for standard read), followed by a 24-bit address. The chip then sends back the data starting from that address. You can keep reading as many bytes as you need.

    Tip: If you need even faster speeds, use Quad SPI mode. This mode can reach data rates up to 66 MB/s, which is much faster than standard SPI.

    If you get unexpected data, check your SPI mode and clock speed. Make sure your chip select pin works as expected.

    Write

    Writing data to the W25Q128JVSIQ takes a few steps. You must first enable writing, then send the write command and the data.

    The chip uses pages for writing. Each page is 256 bytes.

    Specification

    Value

    Minimum Page Size

    256 bytes

    Write Cycle Time

    3 ms (word/page programming)

    Here is a typical write sequence:

    1. Send the Write Enable command (0x06).

    2. Send the Page Program command (0x02), followed by the 24-bit address.

    3. Send up to 256 bytes of data.

    4. Wait for the write to finish by checking the status register.

    Note: Never try to write more than 256 bytes at once. If you do, the chip will wrap the data around to the start of the page.

    You should always check the busy bit in the status register before starting another operation. This step keeps your data safe and prevents errors.

    Erase

    You can erase data in sectors, blocks, or the whole chip. Erasing sets all bits in the selected area to 1 (0xFF). You must always send a Write Enable command before any erase.

    Erase Command

    Size

    Opcode

    Execution Time

    Sector Erase

    4 KB

    0x20

    Not explicitly stated

    Block Erase

    32 KB

    0x52

    Not explicitly stated

    Block Erase

    64 KB

    0xD8

    Not explicitly stated

    Chip Erase

    Entire chip

    0xC7

    Up to 200 seconds max

    Parameter

    Value

    Sector Size

    4 KB

    Block Sizes

    32 KB, 64 KB

    Maximum Chip Erase Time

    200 seconds

    To erase a sector or block, follow these steps:

    1. Send the Write Enable command.

    2. Send the erase command (0x20, 0x52, or 0xD8) with the 24-bit address.

    3. Wait for the busy bit in the status register to clear.

    4. Read back the erased area. All bytes should be 0xFF.

    1. Before any erase operation (4KB, 32KB, 64KB sector erase or chip erase), issue a Write Enable instruction to prepare the device for modification.

    2. Send the appropriate erase command along with the 24-bit memory address for sector erases, or just the command for chip erase.

    3. Poll the status register's busy bit to wait until the erase operation completes, ensuring the device is ready for the next operation.

    4. Verify the success of the erase by reading back the erased memory addresses; the data should read as 0xFF, indicating all bits are set to 1.

    If you see data other than 0xFF after erasing, check your command sequence and make sure you waited long enough for the operation to finish.

    Troubleshooting Tip: Always check the status register after write or erase commands. If the busy bit stays set, your chip may need more time or there may be a wiring problem.

    Troubleshooting & Best Practices

    SPI Issues

    You may face SPI communication problems when working with the W25Q128JVSIQ. Many users report issues like getting wrong data from the status register or seeing strange signals on the data lines. These problems often come from incorrect chip select (CS) handling or mismatched SPI settings. Always make sure you pull the CS pin low during commands and set it high when done. Double-check that your SPI clock polarity and phase match the datasheet.

    🛠️ Tip: Use a logic analyzer or oscilloscope to check the SPI lines. Look for clean signals on MOSI, MISO, SCK, and CS. If you see noise or glitches, try shorter wires or lower the SPI speed.

    If you still have trouble, test your setup with a known working device. Review your code to confirm you send the right commands at the right time. Sometimes, a software reset can help recover from errors.

    Data Integrity

    Keeping your data safe is very important. You should always use a stable power supply. Voltage drops or spikes can cause data loss or corruption. Make sure you operate the chip within the recommended temperature range. Too much heat can damage the memory.

    • Use error correction codes (ECC) to catch and fix mistakes during reads and writes.

    • Handle the chip carefully to avoid static electricity or physical damage.

    • Back up important data often.

    Note: If you see random errors, check your power supply and make sure your control signals are timed correctly.

    Wear Leveling

    Flash memory like the W25Q128JVSIQ has a limited number of program and erase cycles per sector. The manufacturer rates each sector for at least 100,000 cycles.

    Parameter

    Value

    Minimum Endurance (Cycles)

    100,000

    To make your chip last longer, spread out your write and erase operations across different sectors. This process is called wear leveling. Many file systems and libraries can help with this. Avoid writing to the same spot over and over.

    💡 Tip: Use command line tools or serial monitors to check memory health and debug problems. These tools help you spot issues early and keep your project running smoothly.

    To use flash memory in your project, follow these steps:

    1. Choose the right SPI mode for your needs.

    2. Check the pinout and layout before wiring.

    3. Use memory features like page size and erase options.

    4. Add software reset for stability.

    5. Confirm power supply matches device needs.

    6. Use CAD models for your PCB design.

    📄 The official datasheet from ariat-tech.com gives you all the technical details you need.

    • For help, visit the Arduino Forums or the SPIMemory GitHub page.

    • Try different setups and learn from each experiment.

    FAQ

    How do you connect the W25Q128JVSIQ to an Arduino?

    You connect the chip’s pins to the Arduino’s SPI pins. Use digital pins for CS, MOSI, MISO, and SCK. Add a 0.1 µF capacitor between VCC and GND. Check your wiring before powering up.

    Can you use the W25Q128JVSIQ with 5V logic?

    No, you cannot use 5V logic directly. The chip works with 3.3V signals. Use a logic level shifter if your microcontroller uses 5V. This keeps the chip safe from damage.

    What happens if you write more than 256 bytes in one page program?

    The chip wraps extra data to the start of the page. You may overwrite earlier data. Always split your data into 256-byte chunks. This prevents data loss.

    How do you check if a write or erase finished?

    Read the status register. Look for the busy bit (bit 0). If it is 0, the operation finished. If it is 1, wait a bit longer. Use this code:

    while (read_status() & 0x01) { /* wait */ }
    

    Why does your flash memory return only 0xFF when reading?

    You may have a wiring problem, wrong SPI settings, or the chip select pin may not work. Double-check your connections. Make sure you use the right SPI mode and speed.

    See Also

    A Comprehensive Guide To Microcontrollers And Flash Memory

    Exploring Industrial D Flash Microcontrollers And Their Uses

    Best Microcontrollers For Embedded Systems To Watch In 2025

    Key Innovations Shaping Memory Chip Production Domestically In 2025

    Selecting The Ideal Low-Power MCU For Your Next Project

    GNS Electronics is an electronic components distributor expert.