Intermediate
30 min

Add data storage to any application with GD5F2GQ5UEYIGR and PIC32MZ1024EFH064

Improve your memory

Flash 8 Click with PIC32MZ clicker

Published Mar 07, 2023

Click board™

Flash 8 Click

Dev Board

PIC32MZ clicker

Compiler

NECTO Studio

MCU

PIC32MZ1024EFH064

Highly reliable memory solution

A

A

Hardware Overview

How does it work?

Flash 8 Click is based on the GD5F2GQ5UEYIGR, a highly reliable serial Flash memory solution offering flexibility designed for use in various consumer applications from GigaDevice Semiconductor. It comes with a density of 2Gb based on an industry-standard NAND Flash memory core, representing an attractive alternative to SPI-NOR and standard parallel NAND Flash with advanced features. Organized as 256Mx8, the GD5F2GQ5UEYIGR has advanced security features (8K-Byte OTP region). It specifies a minimum of 100.000 endurance cycles with data retention of a minimum of 10 years, allowing it to handle unlimited reads/writes to the memory. This Click board™ communicates with MCU through an industry-standard SPI interface (Dual and QSPI compatible) that enables high clock speed,

supporting the two most common SPI modes, SPI Mode 0 and 3, with a maximum frequency of 104MHz. It is programmed/read in page-based operations and erased in block-based operations. Data is transferred to/from the NAND Flash memory array, page by page, to a data register and a cache register which is closest to I/O control circuits, acting as a data buffer for the I/O data (enable page and random data READ/WRITE and copy back operations). In addition to the SPI communication, this Click board™ also has two additional pins used for Write Protection and HOLD function routed to the RST and PWM pins of the mikroBUS™ socket. The configurable Write Protection, marked as WP and routed on the RST pin of the mikroBUS™ socket, prevents the block lock bits from being overwritten and must be held

low to inhibit all the write operations to registers. When this pin is low, also by setting the appropriate bits, all memory and register write are prohibited, and the address counter is not incremented. On the other hand, the HOLD pin labeled as HLD and routed to the PWM pin of the mikroBUS™ socket stops any serial communications with the device. Still, it doesn’t stop the operation of reading programming or erasing in progress. This Click board™ can only be operated from a 3.3V logic voltage level. Therefore, the board must perform appropriate logic voltage 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 8 Click top side image
Flash 8 Click lateral side image
Flash 8 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

NC
NC
AN
QSPI IO2 / Write Protection
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
QSPI IO3 / 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 8 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 8 Click driver.

Key functions:

  • flash8_write_memory Flash 8 write memory function.

  • flash8_read_memory Flash 8 read memory function.

  • flash8_read_id Flash 8 read ID function.

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 Flash8 Click example
 *
 * # Description
 * This library contains API for Flash 8 Click driver.
 * The library using SPI serial interface.
 * The library also includes a function for write and read memory
 * as well as write protection control functions.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of SPI module and log UART.
 * After driver initialization and default setting, 
 * involves disabling write protection and hold, 
 * the app writes demo_data string ( mikroE ) starting 
 * from the selected row_address of the 123 ( 0x0000007B ) 
 * and column_address of the 456 ( 0x01C8 ).
 *
 * ## Application Task
 * This is an example that shows the use of a Flash 8 Click board™.
 * The app reads a data string, which we have previously written to memory, 
 * starting from the selected row_address of the 123 ( 0x0000007B ) 
 * and column_address of the 456 ( 0x01C8 ).
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "flash8.h"

static flash8_t flash8;
static log_t logger;

static uint8_t manufacture_id;
static uint8_t device_id;
static uint8_t organization_id;
static uint8_t feature_status_out;
static uint8_t demo_data[ 9 ] = { 'M', 'i', 'k', 'r', 'o', 'E', 13 ,10 , 0 };
static uint8_t rx_data[ 9 ] = { 0 };
static feature_cfg_t feature_data;

void application_init ( void ) 
{
    log_cfg_t log_cfg;        /**< Logger config object. */
    flash8_cfg_t flash8_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.
    flash8_cfg_setup( &flash8_cfg );
    FLASH8_MAP_MIKROBUS( flash8_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == flash8_init( &flash8, &flash8_cfg ) ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }

    flash8_default_cfg ( &flash8 );
    log_info( &logger, " Application Task " );
    Delay_ms ( 100 );
    
    flash8_read_id( &flash8, &manufacture_id, &device_id, &organization_id );
    log_printf( &logger, "--------------------------\r\n" );
    log_printf( &logger, "  Manufacture ID  : 0x%.2X\r\n", ( uint16_t) manufacture_id );
    log_printf( &logger, "  Device ID       : 0x%.2X\r\n", ( uint16_t) device_id );
    log_printf( &logger, "  Organization ID : 0x%.2X\r\n", ( uint16_t) organization_id );
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 100 );   
      
    flash8_sw_reset( &flash8, &feature_status_out );
    if ( feature_status_out & FLASH8_GET_PRG_F_PROGRAM_FAIL ) 
    {
        log_printf( &logger, "\tProgram Fail \r\n" );    
    } 
    else 
    {
        log_printf( &logger, "\tProgram Pass \r\n" );    
    }
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 1000 );
    
    feature_data.brwd   = FLASH8_SET_BRWD_ENABLE;
    feature_data.bl     = FLASH8_SET_BL_ALL_UNLOCKED;
    feature_data.idr_e  = FLASH8_SET_IDR_E_NORMAL_OPERATION;
    feature_data.ecc_e  = FLASH8_SET_ECC_E_INTERNAL_ECC_ENABLE;
    feature_data.prt_e  = FLASH8_SET_PRT_E_NORMAL_OPERATION;
    feature_data.hse    = FLASH8_SET_HSE_HIGH_SPEED_MODE_ENABLE;
    feature_data.hold_d = FLASH8_SET_HOLD_D_HOLD_IS_ENABLED;
    feature_data.wel    = FLASH8_SET_WEL_WRITE_ENABLE;
    flash8_set_config_feature( &flash8, feature_data );
    Delay_ms ( 100 );
    
    flash8_block_erase( &flash8, 123, &feature_status_out );
    if ( feature_status_out & FLASH8_GET_ERS_F_ERASE_FAIL ) 
    {
        log_printf( &logger, "\tErase Fail \r\n" );    
    } 
    else 
    {
        log_printf( &logger, "\tErase Pass \r\n" );    
    }
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 1000 );
    
    log_printf( &logger, "   Write data : %s", demo_data );
    log_printf( &logger, "--------------------------\r\n" );
    log_printf( &logger, "        Write status:\r\n"  );
    flash8_write_memory( &flash8, 123, 456, &demo_data[ 0 ], 9, &feature_status_out );
    if ( feature_status_out & FLASH8_GET_OIP_BUSY_STATE ) 
    {
        log_printf( &logger, " Operation is in progress.\r\n" );    
    } 
    else 
    {
        log_printf( &logger, " Operation is not in progress.\r\n" );    
    }
    log_printf( &logger, "- - - - - - - - - - -  - -\r\n" );
    Delay_ms ( 1000 );
    
    log_printf( &logger, "    Check data ready...\r\n" );  
    while ( FLASH8_GET_OIP_READY_STATE != feature_status_out ) 
    {
        flash8_get_feature( &flash8, FLASH8_FEATURE_C0, &feature_status_out );
        log_printf( &logger, "\tBusy state.\r\n" );  
        Delay_ms ( 100 );    
    }
    
    if ( FLASH8_GET_OIP_READY_STATE == feature_status_out ) 
    {
        log_printf( &logger, "\tReady state.\r\n" );    
    }
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void ) 
{   
    flash8_read_memory( &flash8, 123, 456, &rx_data[ 0 ], 9, &feature_status_out );
    log_printf( &logger, "    Read data : %s", rx_data );
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ 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.