Intermediate
30 min

Achieve best-in-class non-volatile memory with long data retention using MR25H256 and PIC18F57Q43

Dive into the world of MRAM

MRAM Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

MRAM Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Trust MRAM as your data's guardian. Our solution offers persistent memory with rapid read and write capabilities, ensuring data integrity and fast access for applications where reliability is paramount.

A

A

Hardware Overview

How does it work?

MRAM Click is based on the MR25H256, a 256 kilobits serial SPI MRAM memory module from Everspin company. This module contains 262,144 bits of memory that can be randomly accessed. The pinout of the used memory module is the same as most commonly used EEPROM modules so that it can directly replace it. The usual SPI lines - SO, SI, SCK and #CS pins from the MR25H256 IC are routed to the mikroBUS™ SPI port (MISO, MOSI, SCK and CS pins). Besides the SPI serial bus, there are two more pins routed to the mikroBUS™. The #HOLD pin of the MR25H256 IC is routed to the INT pin of the mikroBUS™ and it is used to hold the data transfer. When this pin is pulled to a LOW logic level, all data transfer operations are suspended. However, this function is enabled only when the device is already addressed with the CS pin pulled to a LOW level.

This allows to pause the data transfer and resume it later without the need to first address it via the CS pin, reducing the output latency that way. While the data transfer is paused, the SO pin will switch to a high impedance mode (HIGH Z) and will remain inactive. The SCK pulses are completely ignored. The #HOLD pin of the MR25H256 IC is pulled to a HIGH logic level by an onboard pull-up resistor. The #WP pin of the MR25H256 IC is routed to the INT pin of the mikroBUS™ and it is used to prevent writes to the status register, acting as a hardware write protect pin. It is routed to the RST pin of the mikroBUS™. The logical organization of the moduke, such as read and write commands and the status register of the MR25H256 IC are the same as with most commonly used EEPROM modules, such as the one used in EEPROM 4 Click. That allows this

memory module, as well as MRAM click to replace the existing EEPROM module with not too much additional work. The provided libraries offer all the functions needed to work with the MRAM click. Their usage is demonstrated in the included example application which can be used as a reference for further development. The device should wait for the system voltage to become stable before the writing is attempted. 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.

MRAM Click top side image
MRAM Click bottom side 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
Write Protect
PA7
RST
SPI Chip Select
PD4
CS
SPI Clock
PC6
SCK
SPI Data OUT
PC5
MISO
SPI Data IN
PC4
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Data Transfer 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

Schematic

MRAM 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
Barometer 13 Click front image hardware assembly
PIC18F57Q43 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Curiosity Nano with PICXXX MB 1 - 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
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

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 MRAM Click driver.

Key functions:

  • mram_write_data_bytes - Function writes n bytes of data from the buffer

  • mram_read_data_bytes - Function reads n bytes of data and saves it in buffer

  • mram_enable_write_protect - Function enables or disables write protect.

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 
 * \brief MRAM Click example
 * 
 * # Description
 * This example writes and reads from the Mram Click and displays it on the terminal.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes click driver.
 * 
 * ## Application Task  
 * Writes 10 bytes of buffer data in memory with start address 0x0001. Then reads
 * 10 bytes from memory with start address 0x0001 and shows result on USB UART.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "mram.h"

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

static mram_t mram;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    mram_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.

    mram_cfg_setup( &cfg );
    MRAM_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    mram_init( &mram, &cfg );
    mram_default_cfg( &mram );
    
}

void application_task ( void )
{
    uint8_t number_bytes_write;
    uint8_t number_bytes_read;
    uint16_t i;
    uint8_t data_write[ 10 ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    uint8_t data_read[ 20 ] = { 0 };
    
    number_bytes_write = 10;
    number_bytes_read = 10;

    log_printf( &logger, " Data written!\r\n" );
    mram_write_data_bytes ( &mram, 0x0001, data_write, number_bytes_write );
    
    log_printf( &logger, " Read data:\r\n" );
    mram_read_data_bytes ( &mram, 0x0001, data_read, number_bytes_read );
    
    for ( i = 0; i < number_bytes_read; i++ )
    {
        log_printf( &logger, "%d ", ( uint16_t )data_read[ i ] );
    }
    
    log_printf( &logger, "\n" );

    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.