Intermediate
30 min
0

Add data storage to any application with GD5F2GQ5UEYIGR and PIC18LF25K80

Improve your memory

Flash 8 Click with EasyPIC v8

Published Nov 01, 2023

Click board™

Flash 8 Click

Development board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18LF25K80

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

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

3648

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
QSPI IO2 / Write Protection
RA0
RST
SPI Chip Select
RA5
CS
SPI Clock
RC3
SCK
SPI Data OUT
RC4
MISO
SPI Data IN
RC5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
QSPI IO3 / SPI Suspension
RC1
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
2

Take a closer look

Schematic

Flash 8 Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Rotary B 2 Click front image hardware assembly
MCU DIP 28 hardware assembly
EasyPIC v8 28pin-DIP - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

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 char demo_data[ 9 ] = { 'm', 'i', 'k', 'r', 'o', 'E', 13 ,10 , 0 };
static char rx_data[ 9 ];
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 );
    err_t init_flag  = flash8_init( &flash8, &flash8_cfg );
    if ( init_flag == SPI_MASTER_ERROR ) {
        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", manufacture_id );
    log_printf( &logger, "  Device ID       : 0x%.2X\r\n", device_id );
    log_printf( &logger, "  Organization ID : 0x%.2X\r\n", 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 ( feature_status_out != FLASH8_GET_OIP_READY_STATE ) {
        flash8_get_feature( &flash8, FLASH8_FEATURE_C0, &feature_status_out );
        log_printf( &logger, "\tBusy state.\r\n" );  
        Delay_ms( 100 );    
    }
    
    if (  feature_status_out == FLASH8_GET_OIP_READY_STATE ) {
        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( 2000 );
}

void main ( void ) {
    application_init( );

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

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

Additional Support

Resources