TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (385 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139845 times)
  2. FAT32 Library (72209 times)
  3. Network Ethernet Library (57392 times)
  4. USB Device Library (47740 times)
  5. Network WiFi Library (43364 times)
  6. FT800 Library (42700 times)
  7. GSM click (29980 times)
  8. mikroSDK (28440 times)
  9. PID Library (26989 times)
  10. microSD click (26398 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

nvSRAM 3 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.15

mikroSDK Library: 2.0.0.0

Category: SRAM

Downloaded: 169 times

Not followed.

License: MIT license  

nvSRAM 3 Click is a compact add-on board that contains the most reliable nonvolatile memory.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "nvSRAM 3 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "nvSRAM 3 Click" changes.

Do you want to report abuse regarding "nvSRAM 3 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


nvSRAM 3 Click

nvSRAM 3 Click is a compact add-on board that contains the most reliable nonvolatile memory.

nvsram3_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jan 2021.
  • Type : I2C type

Software Support

We provide a library for the nvSRAM3 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 nvSRAM3 Click driver.

Standard key functions :

  • nvsram3_cfg_setup Config Object Initialization function.

    void nvsram3_cfg_setup ( nvsram3_cfg_t *cfg );
  • nvsram3_init Initialization function.

    NVSRAM3_RETVAL nvsram3_init ( nvsram3_t *ctx, nvsram3_cfg_t *cfg );
  • nvsram3_default_cfg Click Default Configuration function.

    void nvsram3_default_cfg ( nvsram3_t *ctx );

Example key functions :

  • nvsram3_memory_write This function write a desired number of data bytes starting from the selected memory address by using I2C serial interface.

    err_t nvsram3_memory_write ( nvsram3_t *ctx, uint32_t mem_addr, uint8_t *data_in, uint8_t n_bytes );
  • nvsram3_memory_read This function reads a desired number of data bytes starting from the selected memory address by using I2C serial interface.

    err_t nvsram3_memory_read ( nvsram3_t *ctx, uint32_t mem_addr, uint8_t *data_out, uint8_t n_bytes );
  • nvsram3_get_rtc_time This function get RTC time data structure.

    void nvsram3_get_rtc_time ( nvsram3_t *ctx, nvsram3_rtc_time_t *rtc_time );

Example Description

The demo application shows how to write/read data to/from nvSRAM memory. It also sets RTC date and time, then reads it in an infinite loop and displays results on USB UART each second.

The demo application is composed of two sections :

Application Init

Initializes device, reads the device ID, writes desired message to memory and sets RTC date and time.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    nvsram3_cfg_t nvsram3_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.

    nvsram3_cfg_setup( &nvsram3_cfg );
    NVSRAM3_MAP_MIKROBUS( nvsram3_cfg, MIKROBUS_1 );
    err_t init_flag = nvsram3_init( &nvsram3, &nvsram3_cfg );

    if ( init_flag == I2C_MASTER_ERROR ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    log_printf( &logger, "-----------------------\r\n" );
    log_printf( &logger, "     nvSRAM 3 Click    \r\n" );
    log_printf( &logger, "-----------------------\r\n" );

    nvsram3_default_cfg ( &nvsram3 );
    Delay_ms ( 100 );

    log_printf( &logger, " DEVICE ID: 0x%.8LX\r\n", nvsram3_get_device_id( &nvsram3 ) );
    log_printf( &logger, "-----------------------\r\n" );
    Delay_ms ( 100 );

    memory_addr = 0x10000;

    log_printf( &logger, "  Write data : %s", demo_data );
    nvsram3_memory_write( &nvsram3, memory_addr, &demo_data[ 0 ], 9 );
    log_printf( &logger, "-----------------------\r\n" );
    Delay_ms ( 1000 );

    date.day_of_week = 4;
    date.day = 31;
    date.month = 12;
    date.year = 2020;
    nvsram3_set_rtc_date( &nvsram3, date );
    Delay_ms ( 100 );

    time.hours = 23;
    time.min = 59;
    time.sec = 50;
    nvsram3_set_rtc_time( &nvsram3, time );
    Delay_ms ( 100 );
}

Application Task

Reads current date and time and then reads the message that we have previusly stored in the memory. All data is being logged on USB UART.


void application_task ( void )
{
    nvsram3_get_rtc_time( &nvsram3, &time );
    nvsram3_get_rtc_date( &nvsram3, &date );

    if ( time.sec != new_sec ) 
    {
        log_printf( &logger, "  Date      : %.2d-%.2d-%.4d\r\n", ( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
        log_printf( &logger, "  Time      : %.2d:%.2d:%.2d\r\n", ( uint16_t ) time.hours, ( uint16_t ) time.min, ( uint16_t ) time.sec );
        log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
        new_sec = time.sec;

        if ( date.year != c_year ) 
        {
            log_printf( &logger, "     Happy New Year    \r\n" );
            c_year = date.year;
        } 
        else 
        {
            nvsram3_memory_read( &nvsram3, memory_addr, &rx_data[ 0 ], 9 );
            log_printf( &logger, "  Read data : %s", rx_data );    
        }

        log_printf( &logger, "-----------------------\r\n" );
    } 
    else 
    {
        Delay_ms ( 500 );    
    }
}

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.nvSRAM3

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.


ALSO FROM THIS AUTHOR

DC Motor 2 Click

0

DC MOTOR 2 Click carries the TB6593FNG driver IC for direct current motors. With two pairs of screw terminals (power supply and outputs), the Click board can drive motors with voltages from 2.5 to 13V (output current of up to 1.2 amps with peaks up to 3.2 amps) . The PWM signal drives the motor while the IN1 and IN2 pins provide binary direction signals that set the direction of the motor (clockwise or counter clockwise), or apply stop or short brake functions.

[Learn More]

Cap Extend Click

0

Cap Extend Click is a mikroBUS add-on board with a SEMTECH SX8633 low power, capacitive button touch controller. It has 12 pins for connecting capacitive inputs (either touch-buttons or proximity sensors).

[Learn More]

GainAMP click

11

GainAMP click carries the LTC®6912 dual channel, low noise, digitally programmable gain amplifier (PGA). The click is designed to work on either 3.3V or 5V power supply. It communicates with the target MCU over SPI interface, with additional functionality provided by the following pins on the mikroBUS line: AN, RST.

[Learn More]