Intermediate
30 min

Secure data integrity with CY15B104Q and ATmega328

FRAM unveils the future of data handling!

FRAM 2 Click with Arduino UNO Rev3

Published Feb 14, 2024

Click board™

FRAM 2 Click

Dev Board

Arduino UNO Rev3

Compiler

NECTO Studio

MCU

ATmega328

Utilize FRAM's non-volatile and fast-write characteristics to ensure data integrity and responsiveness in critical systems

A

A

Hardware Overview

How does it work?

FRAM 2 Click is based on the CY15B104Q, a 4 Mbit serial ferroelectric (FRAM) module from Infineon. It contains 4,194,304 bits of memory, organized in 524,288 byes. This means that the storage area contains 512 KB of address space. This memory IC is manufactured using ferroelectric technology, which has many advantages over the conventional technologies used for manufacturing EEPROM and FLASH memory modules. Ferroelectric technology is still being developed and perfected, but the advantages have already been demonstrated. This technology exploits the properties of ferroelectric materials to retain the electric field after exposure, the same way the ferromagnetic materials retain their magnetic field. This phenomenon is employed to polarize the FRAM cells and store the information. One area that still needs improvement is the thermal instability, especially at high temperatures. When the ferroelectric material reaches the Curie temperature, its properties are degraded. Therefore, the high temperature might damage the content of the FRAM module. This is illustrated by the data retention period: while working at 85˚C, the data retention period is reduced to 10 years. At 65˚C, the data retention period stretches to over 150 years. Still, combined with the endurance of 1014 read/write cycles at bus write speed, this type of memory still represents an ideal solution for applications with frequent writing to non-volatile memory locations. This Click board™ uses the SPI communication protocol, allowing fast serial clock rates. The device employs certain protection mechanisms to ensure reliable data transactions and avoid accidental writing to the memory array. The WEL bit must be set before

writing any data to the IC, which modifies registers or the array itself. This bit is cleared after or during every memory modification instruction. Therefore, every memory modification instruction must be prefixed with the Write Enable (WREN) instruction that sets this bit to 1. This mechanism ensures that only the intended write instruction will be executed. The host MCU initiates Communication with the device, which drives the chip select pin (#CS on the schematic) to a LOW logic level. This pin is routed to the mikroBUS™ CS pin. The next byte of information can be either command or data. Usually, the first byte is the instruction (command) followed by the memory address. Depending on the command sent, either the memory is written to or read from the specific memory address. The memory address on this device is 19-bit (0x00000 to 0x7FFFF), and therefore, it is sent by 3 bytes. Several instruction codes can be sent after the CS pin is driven to a LOW logic level. These include Write Enable, Write to the memory array, Read from the memory array, Write Status Register, Read Status Register, and so on. For a full list of commands and their detailed description, please refer to the datasheet of the CY15B104Q IC. When using the write-to-array instruction, it is possible to write the whole array while keeping the CS line to a LOW logic level, as the internal address pointer will increase with each received byte of data. Once the end of the array is reached (address 0x7FFFF), the internal pointer will roll over from the beginning (0x00000). An obvious advantage over the traditional EEPROM can be observed here: on a traditional EEPROM, the memory is organized in pages, usually 256 bytes long, which allows

buffering of the data because of the inherently slow write operation. The FRAM memory does not use pages because the memory is written faster than the SPI bus can deliver new information (the data is written at bus speed). Therefore, no buffering is required, and the whole array can be sequentially written. The CY15B104Q includes the write protection of the specific parts or the whole memory array. The write protection consists of two bits in the Status Register (B0, B1). The Write Status Register instruction can set or reset these bits. B0 and B1 bits control the write-protect status of the memory array (from one-quarter to full memory array protection). These bits are non-volatile, and their state is retained between the power cycles. The #WP pin is used to lock the Status Register. When this pin is driven to a LOW level, no further modifications to the Status register are possible, and the instructions used to change bits in this register (Write Enable and Write Status Register) are completely ignored. Driving this pin to a LOW state effectively acts as the hardware memory write-protect lock mechanism. The WPEN bit of the status register can completely turn off this pin: if the WPEN bit is cleared (0), this pin will not affect the CY15B104Q IC. The #WP pin is routed to the mikroBUS™ RST pin and labeled as WP. The FRAM 2 click allows hold of the communication in progress. If the #HOLD pin is driven to a LOW logic level on the LOW pulse of the serial clock signal (SCK), the communication will be paused but not aborted. Driving this pin to a HIGH logic level will resume the data transfer. This pin is routed to the mikroBUS™ PWM pin, labeled as HLD.

FRAM 2 Click top side image
FRAM 2 Click bottom side image

Features overview

Development board

Arduino UNO is a versatile microcontroller board built around the ATmega328P chip. It offers extensive connectivity options for various projects, featuring 14 digital input/output pins, six of which are PWM-capable, along with six analog inputs. Its core components include a 16MHz ceramic resonator, a USB connection, a power jack, an

ICSP header, and a reset button, providing everything necessary to power and program the board. The Uno is ready to go, whether connected to a computer via USB or powered by an AC-to-DC adapter or battery. As the first USB Arduino board, it serves as the benchmark for the Arduino platform, with "Uno" symbolizing its status as the

first in a series. This name choice, meaning "one" in Italian, commemorates the launch of Arduino Software (IDE) 1.0. Initially introduced alongside version 1.0 of the Arduino Software (IDE), the Uno has since become the foundational model for subsequent Arduino releases, embodying the platform's evolution.

Arduino UNO Rev3 double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

32

RAM (Bytes)

2048

You complete me!

Accessories

Click Shield for Arduino UNO has two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the Arduino UNO board without effort. The Arduino Uno, a microcontroller board based on the ATmega328P, provides an affordable and flexible way for users to try out new concepts and build prototypes with the ATmega328P microcontroller from various combinations of performance, power consumption, and features. The Arduino Uno has 14 digital input/output pins (of which six can be used as PWM outputs), six analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header, and reset button. Most of the ATmega328P microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the Arduino UNO board with our Click Shield for Arduino UNO, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Arduino UNO accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Write Protect
PD2
RST
SPI Chip Select
PB2
CS
SPI Clock
PB5
SCK
SPI Data OUT
PB4
MISO
SPI Data IN
PB3
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Data Transfer Pause
PD6
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

FRAM 2 Click Schematic schematic

Step by step

Project assembly

Click Shield for Arduino UNO front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Arduino UNO Rev3 as your development board.

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Barometer 13 Click front image hardware assembly
Prog-cut hardware assembly
Arduino UNO Rev3 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
Arduino UNO 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for FRAM 2 Click driver.

Key functions:

  • fram2_read - This function reads content from address and saves it to buffer

  • fram2_write - This function writes content from buffer to address

  • fram2_read_status - This function reads content of FRAM status register

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 FRAM2 Click example
 * 
 * # Description
 * This example performs write & read operation to certain register.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initiazlize device and enable write operation.
 * 
 * ## Application Task  
 * Write value 42 to register 0x10 and check if operation was done properly.
 * 
 * *note:* 
 * data_to_write variable is declared as const, so compiler may warn user 
 * about 'suspisuous pointer conversion'. Note it is the case only with this
 * code snippet but user has freedom to use driver functions as he wishes.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "fram2.h"
#include <string.h>

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

static fram2_t fram2;
static log_t logger;

static uint8_t data_to_write[ 3 ] = { '4', '2', 0 };
static uint8_t read_buf [ 32 ];
static uint32_t test_addr;

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

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

    fram2_cfg_setup( &cfg );
    FRAM2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    fram2_init( &fram2, &cfg );
    fram2_default_cfg ( &fram2 );
}

void application_task ( void )
{
    log_info( &logger, "Writing value 42 into register 0x10..." );  
    test_addr = 0x0010;  
    fram2_write( &fram2, test_addr, data_to_write, 3 );
    Delay_ms( 200 );

    log_info( &logger, "Reading from register 0x10..." );
    memset( read_buf, 0, 32 );
    Delay_ms( 500 );
    
    fram2_read( &fram2, test_addr, read_buf, 3 );
    log_printf ( &logger, "Read value: %s\r\n\n", read_buf );
    Delay_ms( 500 );
}

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.