Intermediate
30 min

Maintain integrity and privacy for your critical information using AT25M02 and PIC32MZ2048EFH100

Data that last

EEPROM 4 Click with Flip&Click PIC32MZ

Published Aug 23, 2023

Click board™

EEPROM 4 Click

Dev. board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Discover a solution that guarantees data retention for extended periods, offering peace of mind in critical scenarios and safeguarding valuable information against unforeseen events

A

A

Hardware Overview

How does it work?

EEPROM 4 Click is based on the AT25M02, an SPI serial EEPROM from Microchip, with a memory cell density of 2 Mbits. The EEPROM density is usually expressed in bits, so exactly 2,097,152 bits are organized in units or words of 8 bits, which gives 262,144 bytes of data memory. Furthermore, the EEPROM is organized into so-called pages. One page holds 256 bytes, and there are 1024 pages (1024 pages x 256 bytes = 262,144 bytes total). Having insight into how the memory cells are organized is important for write and erase operations. The SPI pins are routed to the mikroBUS™, making communication easy and straightforward. The SPI can be clocked as high as 5MHz, providing a fast throughput for the data transfer. A dedicated #HOLD pin is routed to the PWM pin of the mikroBUS™. When the communication with the click board™ is initiated by setting the CS pin to a LOW logic state, it is possible to pause the serial data transfer without

resetting the communication if the #HOLD pin (PWM pin on the mikroBUS™) is set to a LOW logic state. To resume the communication, setting this pin to a HIGH logic state while the SCK is still running is enough. Once the HOLD is initiated, the state of the SCK line is irrelevant, and any serial data input will be ignored. This pin is pulled HIGH by the onboard resistor. A dedicated #WP write protect pin puts the device into the hardware write protect mode. This pin is routed to the RST pin of the mikroBUS™. Hardware write-protect works with the Write Protect Enable (WPEN) bit of the Status Register. When this bit is set to 1, and the #WP pin is set to a LOW logic state, the device will ignore any attempt to write to the Status Register and the EEPROM memory regions selected by the Block Write Protect bits of the Status Register (BP0 and BP1). WRSR instruction is used to write to the Status Register (01h). Again, WREN instruction should be executed first before 

attempting to write to Status Register. Once the WPEN bit is set to 1 and the RST has been pulled to a LOW logic state, setting the WPEN bit to 0 won’t turn off write protection as long as the #WP pin (RST) stays LOW. WPEN bit and the BP0 and BP1 bits are constructed as EEPROM cells, meaning that they are nonvolatile and will retain their states even after power is off. The #WP pin is pulled HIGH by the onboard resistor. As usual, the onboard SMD jumper labeled as VCCSEL is used to select the operating voltage between 3.3V and 5V. However, there’s the third position for this jumper, which sets the operating voltage to 1.8V. This is achieved thanks to the TC1015, a small 100 mA LDO from Microchip powered by the 5V rail. As always, MikroElektronika provides libraries that simplify and speed up working with this device. The provided application example demonstrates the functionality of the provided libraries and can be used as a reference point for own development.

EEPROM 4 Click top side image
EEPROM 4 Click bottom side image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution 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, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows 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.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Write Protect
RE2
RST
SPI Chip Select
RA0
CS
SPI Clock
RG6
SCK
SPI Data OUT
RC4
MISO
SPI Data IN
RB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Data Transfer Pause
RC14
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

EEPROM 4 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

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

Flip&Click PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ MB1 Access - 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for EEPROM 4 Click driver.

Key functions:

  • eeprom4_write_status_reg - Status register write function

  • eeprom4_write_memory - Memory array write function

  • eeprom4_read_memory - Memory array read function

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 
 * \brief Eeprom4 Click example
 * 
 * # Description
 * This click reads and writes memory.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes click driver and configures click that all memory block > is unprotected.
 * Also configures that HOLD operation is disabled, and the memory and > status register are writable.
 * 
 * ## Application Task  
 * Enables writting to memory array, writes data from buffer to memory,
 * checks if the part is in a write cycle, and if is not reads data >  > from memory array and stores data to buffer.
 * Storaged data shows on USB UART. 
 *  
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "eeprom4.h"

// ------------------------------------------------------------------ VARIABLES

static eeprom4_t eeprom4;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    eeprom4_cfg_t cfg;

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

    eeprom4_cfg_setup( &cfg );
    EEPROM4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    eeprom4_init( &eeprom4, &cfg );
    
    eeprom4_default_cfg( &eeprom4 );
}

void application_task (  )
{
    uint8_t data_write[ 13 ] = { 'M', 'i', 'K', 'r', 'O', 'e', 0 };
    uint8_t data_read[ 255 ] = { 0 };
    uint8_t cnt;
    uint8_t check_state;

    eeprom4_send_command( &eeprom4, EEPROM4_SET_WRITE_ENABLE_LATCH_COMMAND );
    eeprom4_write_memory( &eeprom4, EEPROM4_FIRST_MEMORY_LOCATION, data_write, 6 );

    cnt = eeprom4_check_status_reg( &eeprom4, EEPROM4_READY_BIT );
    check_state = eeprom4_send_command( &eeprom4, EEPROM4_LOW_POWER_WRITE_POLL_COMMAND );
    
    while ( cnt | check_state )
    {
        cnt = eeprom4_check_status_reg( &eeprom4, EEPROM4_READY_BIT );
        check_state = eeprom4_send_command( &eeprom4, EEPROM4_LOW_POWER_WRITE_POLL_COMMAND );
    }
    
    eeprom4_read_memory( &eeprom4, 0x00000000, data_read, 6 );

    for ( cnt = 0; cnt < 6; cnt++ )
    {
        log_printf( &logger, " %c ", data_read[cnt] );
    }
    log_printf( &logger, "-----   \r\n" );
    
    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.