Intermediate
30 min

Create a reliable and secure data storage and transfer with W25Q02JV and PIC32MZ1024EFH064

Got memory? With flash memory, you do!

Flash 9 Click with PIC32MZ clicker

Published Apr 24, 2023

Click board™

Flash 9 Click

Dev Board

PIC32MZ clicker

Compiler

NECTO Studio

MCU

PIC32MZ1024EFH064

Discover a new level of memory performance and security with this SPI serial flash memory solution

A

A

Hardware Overview

How does it work?

Flash 9 Click is based on the W25Q02JV, a highly reliable serial Flash memory solution offering flexibility and performance well beyond ordinary Serial Flash devices from Winbond Electronics. The W25Q02JV represents a four 512Mb stack die where only one can be active at any given time to communicate with the external SPI controller. It supports linear addressing for the full 2Gb memory address range (continuously read accessible only into four separate 512Mb address memory segments). The W25Q02JV array is organized into 1,048,576 programmable pages of 256 bytes each, where up to 256 bytes can be programmed at a time. Pages of the W25Q02JV can be erased in groups of 16 (4KB sector erase), groups of 128 (32KB block erase), groups of 256 (64KB block erase), or the entire chip (chip erase). This IC has 32,768 erasable 4KB sectors and 2,048 erasable 64KB blocks, respectively.

The small 4KB sectors allow for greater flexibility in applications that require data and parameter storage. Also, it specifies a minimum of 100.000 endurance cycles with data retention of a minimum of 20 years, which gives the W25Q02JV the capability to handle unlimited reads/writes to the memory. Flash 9 Click communicates with MCU through a standard SPI interface that enables high clock speed, supporting the two most common SPI modes, SPI Mode 0 and 3. Alongside the internal software Reset sequence, this board has an active-low reset signal routed on the RST pin of the mikroBUS™ socket used to reset the W25Q02JV to the initial power-on state. When this signal is asserted low, any ongoing program/erase operation will be interrupted, and data corruption may happen (the device will not accept any command input). An additional feature of this Click board™

represents the configurable Write Protection function labeled as WP routed on the AN pin of the mikroBUS™ socket. The WP pin protects the entire memory and all registers from write operations and must be set to a low logic state to inhibit all the write operations. Besides, the Flash 9 Click also has an additional hold pin, labeled as HLD, and routed to the PWM pin of the mikroBUS™ socket, allowing the device to be paused while it’s still actively selected. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.

Flash 9 Click top side image
Flash 9 Click lateral side image
Flash 9 Click bottom side image

Features overview

Development board

PIC32MZ Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller with FPU from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access anywhere and under

any circumstances. Each part of the PIC32MZ Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the PIC32MZ Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current, which is more than enough to operate all onboard

and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. PIC32MZ Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

PIC32MZ clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

1024

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

Write Protect
RE4
AN
Reset
RE5
RST
SPI Chip Select
RG9
CS
SPI Clock
RG6
SCK
SPI Data OUT
RG7
MISO
SPI Data IN
RG8
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
SPI Suspension
RB3
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Flash 9 Click Schematic schematic

Step by step

Project assembly

PIC32MZ clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the PIC32MZ clicker as your development board.

PIC32MZ clicker front image hardware assembly
Thermo 26 Click front image hardware assembly
Prog-cut hardware assembly
Micro B Connector clicker - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Flip&Click PIC32MZ MCU step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for Flash 9 Click driver.

Key functions:

  • flash9_erase_memory This function erases the selected amount of memory that contains the selected address.

  • flash9_memory_write This function writes a desired number of data bytes to the memory starting from the selected address.

  • flash9_memory_read_fast This function reads a desired number of data bytes from memory starting from the selected address performing the fast read command.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief Flash9 Click example
 *
 * # Description
 * This example demonstrates the use of Flash 9 click board by writing specified data to
 * the memory and reading it back.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Erases the memory sector and then writes a desired number of data bytes to the memory 
 * and verifies that it is written correctly by reading from the same memory location and 
 * displaying the memory content on the USB UART.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "flash9.h"

#define DEMO_TEXT_MESSAGE           "MikroE - Flash 9 click board"
#define STARTING_ADDRESS            0x01234567ul

static flash9_t flash9;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    flash9_cfg_t flash9_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    flash9_cfg_setup( &flash9_cfg );
    FLASH9_MAP_MIKROBUS( flash9_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == flash9_init( &flash9, &flash9_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( FLASH9_ERROR == flash9_default_cfg ( &flash9 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    uint8_t data_buf[ 128 ] = { 0 };
    if ( FLASH9_OK == flash9_erase_memory ( &flash9, FLASH9_CMD_SECTOR_ERASE_WITH_4BYTE_ADDRESS, 
                                            STARTING_ADDRESS ) )
    {
        log_printf ( &logger, "Sector from address 0x%.8LX has been erased!\r\n", STARTING_ADDRESS );
    }
    Delay_ms ( 500 );
    
    if ( FLASH9_OK == flash9_memory_write ( &flash9, STARTING_ADDRESS, DEMO_TEXT_MESSAGE, 
                                            strlen ( DEMO_TEXT_MESSAGE ) ) )
    {
        log_printf ( &logger, "Data written to address 0x%.8LX: \"%s\"\r\n", STARTING_ADDRESS, 
                                                                  ( char * ) DEMO_TEXT_MESSAGE );
    }
    Delay_ms ( 500 );

    if ( FLASH9_OK == flash9_memory_read_fast ( &flash9, STARTING_ADDRESS, data_buf, 
                                                strlen ( DEMO_TEXT_MESSAGE ) ) )
    {
        log_printf ( &logger, "Data read from address 0x%.8LX: \"%s\"\r\n\n", STARTING_ADDRESS, 
                                                                              data_buf );
    }
    Delay_ms ( 2000 );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.