Beginner
10 min

Create projects with rapid boot times and extensive low-power data storage capabilities using AT25EU0041A and PIC18F57Q43

4Mbit serial flash memory suitable for battery-powered or energy-sensitive applications

Flash 12 Click with Curiosity Nano with PIC18F57Q43

Published Mar 12, 2024

Click board™

Flash 12 Click

Dev. board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Ultra-low power consumption, fast erase times, and the ability to execute code directly from memory makes it an excellent choice for developers looking to optimize their projects for the edge of IoT networks

A

A

Hardware Overview

How does it work?

Flash 12 Click is based on the AT25EU0041A, a 4Mbit serial flash memory from Renesas, known for its ultra-low power consumption. This memory is part of a series specifically developed for applications operating on the IoT network's fringes, where energy efficiency is paramount. The AT25EU0041A is particularly well-suited for battery-operated systems, offering a reliable solution for both program code storage, which is then loaded into embedded systems, and serving as external RAM for direct program execution from the NOR Flash memory. Based on these features, this Click board™ is ideal for various applications from low-power reading and rapid erasure to boot/code shadow memory and straightforward event/data logging. The AT25EU0041A sets a new standard in energy efficiency through its innovative erase architecture, which features short erase times while maintaining low power consumption across all

operations, including reading, programming, and erasing. The consistent erase times, irrespective of the memory block size, and a page-erase capability that allows for as little as 256 bytes to be erased enhance the efficiency of write operations. Moreover, the AT25EU0041A adheres to the JEDEC standard for manufacturer and device identification, and it includes a 128-bit unique serial number, further enhancing its utility and security features. Flash 12 Click communicates with MCU through a standard SPI interface supporting the two most common SPI modes, SPI Mode 0 and 3, and a maximum clock frequency of up to 108MHz. The AT25EU0041A enhances data transfer rates through Dual and Quad SPI operations, which double and quadruple the standard SPI speed, respectively. These enhanced speeds are achieved by re-purposing the SI and SO pins as bidirectional I/O pins during Dual and Quad SPI operations.

Furthermore, the board features a HOLD function, marked as HLD and routed on the default position of the INT pin of the mikroBUS™ socket. The hold function allows the suspension of serial communications without disrupting ongoing operations. The board also has a Write Protect feature, marked as WP and routed on the default position of the PWM of the mikroBUS™ socket, that safeguards all registers and memory from unintended write operations through both hardware and software mechanisms. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

Flash 12 Click hardware overview image

Features overview

Development board

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
ID SEL
PA7
RST
SPI Select / ID COMM
PD4
CS
SPI Clock
PC6
SCK
QSPI IO1 / SPI Data OUT
PC5
MISO
QSPI IO0 / SPI Data IN
PC4
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
QSPI IO2 / Write Protect
PB0
PWM
QSPI IO3 / Communication Pause
PA6
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Flash 12 Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Board mapper by product8 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
PIC18F57Q43 Curiosity 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

Software Support

Library Description

This library contains API for Flash 12 Click driver.

Key functions:

  • flash12_memory_write - This function writes a desired number of data bytes starting to the selected memory address by using SPI serial interface

  • flash12_memory_read - This function reads a desired number of data bytes starting from the selected memory address by using SPI serial interface

  • flash12_erase_memory - This function erases the selected amount of memory which contains the selected address

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief Flash 12 Click example
 *
 * # Description
 * This example demonstrates the use of Flash 12 Click board 
 * by writing specified data to the memory and reading it back.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of SPI module and log UART.
 * After driver initialization, the app sets the default configuration.
 *
 * ## Application Task
 * The demo application writes a desired number of bytes to the memory 
 * and then verifies if it is written correctly by reading 
 * from the same memory location and displaying the memory content.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "flash12.h"

// Starting memory address
#define STARTING_ADDRESS            0x012345

// Demo text messages
#define DEMO_TEXT_MESSAGE_1         "MikroE"
#define DEMO_TEXT_MESSAGE_2         "Flash 12 Click"

static flash12_t flash12;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    flash12_cfg_t flash12_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.
    flash12_cfg_setup( &flash12_cfg );
    FLASH12_MAP_MIKROBUS( flash12_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == flash12_init( &flash12, &flash12_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( FLASH12_ERROR == flash12_default_cfg ( &flash12 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task\r\n" );
}

void application_task ( void )
{
    uint8_t data_buf[ 128 ] = { 0 };

    log_printf( &logger, " Memory address: 0x%.6LX\r\n", ( uint32_t ) STARTING_ADDRESS );
    if ( FLASH12_OK == flash12_erase_memory( &flash12, FLASH12_CMD_BLOCK_ERASE_4KB, STARTING_ADDRESS ) )
    {
        log_printf( &logger, " Erase memory block (4KB)\r\n" );
    }
    memcpy( data_buf, DEMO_TEXT_MESSAGE_1, strlen( DEMO_TEXT_MESSAGE_1 ) );
    if ( FLASH12_OK == flash12_memory_write( &flash12, STARTING_ADDRESS, 
                                                       data_buf, 
                                                       sizeof( data_buf ) ) )
    {
        log_printf( &logger, " Write data: %s\r\n", data_buf );
        Delay_ms ( 100 );
    }

    memset( data_buf, 0, sizeof( data_buf ) );
    if ( FLASH12_OK == flash12_memory_read( &flash12, STARTING_ADDRESS, 
                                                      data_buf, 
                                                      sizeof( data_buf ) ) )
    {
        log_printf( &logger, " Read data: %s\r\n\n", data_buf );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
    }

    log_printf( &logger, " Memory address: 0x%.6LX\r\n", ( uint32_t ) STARTING_ADDRESS );
    if ( FLASH12_OK == flash12_erase_memory( &flash12, FLASH12_CMD_BLOCK_ERASE_4KB, STARTING_ADDRESS ) )
    {
        log_printf( &logger, " Erase memory block (4KB)\r\n" );
    }
    memcpy( data_buf, DEMO_TEXT_MESSAGE_2, strlen( DEMO_TEXT_MESSAGE_2 ) );
    if ( FLASH12_OK == flash12_memory_write( &flash12, STARTING_ADDRESS, 
                                             data_buf, sizeof( data_buf ) ) )
    {
        log_printf( &logger, " Write data: %s\r\n", data_buf );
        Delay_ms ( 100 );
    }
    memset( data_buf, 0, sizeof ( data_buf ) );
    if ( FLASH12_OK == flash12_memory_read( &flash12, STARTING_ADDRESS, 
                                            data_buf, sizeof ( data_buf ) ) )
    {
        log_printf( &logger, " Read data: %s\r\n\n", data_buf );
        Delay_ms ( 1000 );
        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.