mram3  2.0.0.0
Main Page

MRAM 3 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : May 2022.
  • Type : SPI type

Software Support

We provide a library for the MRAM 3 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for MRAM 3 Click driver.

Standard key functions :

Example key functions :

  • mram3_memory_write This function writes a desired number of data bytes starting from the selected memory address.
    err_t mram3_memory_write ( mram3_t *ctx, uint32_t address, uint8_t *data_in, uint32_t len );
  • mram3_memory_read This function reads a desired number of data bytes starting from the selected memory address.
    err_t mram3_memory_read ( mram3_t *ctx, uint32_t address, uint8_t *data_out, uint32_t len );
  • mram3_aug_memory_write This function writes a desired number of data bytes starting from the selected augmented memory address.
    err_t mram3_aug_memory_write ( mram3_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len );

Example Description

This example demonstrates the use of MRAM 3 click board by writing specified data to the memory and reading it back.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
mram3_cfg_t mram3_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
mram3_cfg_setup( &mram3_cfg );
MRAM3_MAP_MIKROBUS( mram3_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == mram3_init( &mram3, &mram3_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( MRAM3_ERROR == mram3_default_cfg ( &mram3 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

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 on the USB UART.

void application_task ( void )
{
uint8_t data_buf[ 128 ] = { 0 };
memcpy ( data_buf, DEMO_TEXT_MESSAGE_1, strlen ( DEMO_TEXT_MESSAGE_1 ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, "Data written to address 0x%.5LX: %s\r\n", ( uint32_t ) STARTING_ADDRESS,
data_buf );
}
memset ( data_buf, 0, sizeof ( data_buf ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, "Data read from address 0x%.5LX: %s\r\n", ( uint32_t ) STARTING_ADDRESS,
data_buf );
Delay_ms ( 3000 );
}
memcpy ( data_buf, DEMO_TEXT_MESSAGE_2, strlen ( DEMO_TEXT_MESSAGE_2 ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, "Data written to address 0x%.5LX: %s\r\n", ( uint32_t ) STARTING_ADDRESS,
data_buf );
}
memset ( data_buf, 0, sizeof ( data_buf ) );
data_buf, sizeof ( data_buf ) ) )
{
log_printf ( &logger, "Data read from address 0x%.5LX: %s\r\n\n", ( uint32_t ) STARTING_ADDRESS,
data_buf );
Delay_ms ( 3000 );
}
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.MRAM3

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


mram3_init
err_t mram3_init(mram3_t *ctx, mram3_cfg_t *cfg)
MRAM 3 initialization function.
MRAM3_MAP_MIKROBUS
#define MRAM3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: mram3.h:246
MRAM3_OK
@ MRAM3_OK
Definition: mram3.h:303
mram3_memory_write
err_t mram3_memory_write(mram3_t *ctx, uint32_t address, uint8_t *data_in, uint32_t len)
MRAM 3 memory write function.
mram3_cfg_t
MRAM 3 Click configuration object.
Definition: mram3.h:279
DEMO_TEXT_MESSAGE_2
#define DEMO_TEXT_MESSAGE_2
Definition: main.c:30
mram3_aug_memory_write
err_t mram3_aug_memory_write(mram3_t *ctx, uint8_t address, uint8_t *data_in, uint8_t len)
MRAM 3 aug memory write function.
application_task
void application_task(void)
Definition: main.c:69
mram3_memory_read
err_t mram3_memory_read(mram3_t *ctx, uint32_t address, uint8_t *data_out, uint32_t len)
MRAM 3 memory read function.
mram3_default_cfg
err_t mram3_default_cfg(mram3_t *ctx)
MRAM 3 default configuration function.
mram3_cfg_setup
void mram3_cfg_setup(mram3_cfg_t *cfg)
MRAM 3 configuration object setup function.
DEMO_TEXT_MESSAGE_1
#define DEMO_TEXT_MESSAGE_1
Definition: main.c:29
mram3_t
MRAM 3 Click context object.
Definition: mram3.h:262
application_init
void application_init(void)
Definition: main.c:33
STARTING_ADDRESS
#define STARTING_ADDRESS
Definition: main.c:31
MRAM3_ERROR
@ MRAM3_ERROR
Definition: mram3.h:304