TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 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 (137080 times)
  2. FAT32 Library (70222 times)
  3. Network Ethernet Library (56094 times)
  4. USB Device Library (46409 times)
  5. Network WiFi Library (42029 times)
  6. FT800 Library (41375 times)
  7. GSM click (29109 times)
  8. mikroSDK (26555 times)
  9. PID Library (26487 times)
  10. microSD click (25483 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 4 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.11

mikroSDK Library: 2.0.0.0

Category: SRAM

Downloaded: 107 times

Not followed.

License: MIT license  

nvSRAM 4 Click is a compact add-on board that contains the most reliable nonvolatile memory. This board features the CY14B101PA, a 1-Mbit nvSRAM with a fully-featured real-time clock from Cypress Semiconductor.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "nvSRAM 4 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "nvSRAM 4 click" changes.

Do you want to report abuse regarding "nvSRAM 4 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


nvSRAM 4 click

nvSRAM 4 Click is a compact add-on board that contains the most reliable nonvolatile memory. This board features the CY14B101PA, a 1-Mbit nvSRAM with a fully-featured real-time clock from Cypress Semiconductor.

nvsram4_click.png

click Product page


Click library

  • Author : Nenad Filipovic
  • Date : Dec 2020.
  • Type : SPI type

Software Support

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

Standard key functions :

  • Config Object Initialization function.

    void nvsram4_cfg_setup ( nvsram4_cfg_t *cfg );
  • Initialization function.

    NVSRAM4_RETVAL nvsram4_init ( nvsram4_t *ctx, nvsram4_cfg_t *cfg );
  • Click Default Configuration function.

    void nvsram4_default_cfg ( nvsram4_t *ctx );

Example key functions :

  • nvSRAM 4 burst read memory function.

    err_t nvsram4_burst_read_memory ( nvsram4_t *ctx, uint32_t mem_addr, uint8_t *data_out, uint8_t n_bytes );
  • nvSRAM 4 burst write memory function.

    err_t nvsram4_burst_write_memory ( nvsram4_t *ctx, uint32_t mem_addr, uint8_t *data_in, uint8_t n_bytes );
  • nvSRAM 4 get RTC time function.

    void nvsram4_get_rtc_time ( nvsram4_t *ctx, nvsram4_rtc_time_t *rtc_time );

Examples Description

This is an example that demonstrates the use of the nvSRAM 4 click board.

The demo application is composed of two sections :

Application Init

Initialization driver enables - SPI, write demo_data string ( mikroE ), starting from the selected memory_addr ( 112233 ), set the time to 12:30:31 and set the date to 31-12-20.

void application_init ( void ) {
    log_cfg_t log_cfg;          /**< Logger config object. */
    nvsram4_cfg_t nvsram4_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_printf( &logger, "\r\n" );
    log_info( &logger, " Application Init " );

    // Click initialization.

    nvsram4_cfg_setup( &nvsram4_cfg );
    NVSRAM4_MAP_MIKROBUS( nvsram4_cfg, MIKROBUS_1 );
    err_t init_flag  = nvsram4_init( &nvsram4, &nvsram4_cfg );
    if ( init_flag == SPI_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    nvsram4_default_cfg ( &nvsram4 );
    Delay_ms ( 100 );
    log_info( &logger, " Application Task " );

    log_printf( &logger, "-----------------------\r\n" );
    log_printf( &logger, "     nvSRAM 4 click    \r\n" );
    log_printf( &logger, "-----------------------\r\n" );

    memory_addr = 112233;

    nvsram4_set_cmd( &nvsram4, NVSRAM4_STATUS_WREN );
    Delay_ms ( 100 );

    log_printf( &logger, "  Write data : %s", demo_data );
    nvsram4_burst_write_memory( &nvsram4, 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 = 20;
    nvsram4_set_rtc_date( &nvsram4, date );
    Delay_ms ( 100 );

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

Application Task

In this example, we read a data string, which we have previously written to memory,

starting from the selected memory_addr ( 112233 ) and read and display the current time and date, which we also previously set. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 1 sec.

void application_task ( void ) {
    nvsram4_get_rtc_time( &nvsram4, &time );
    Delay_ms ( 1 );
    nvsram4_get_rtc_date( &nvsram4, &date );
    Delay_ms ( 1 );

    if ( time.sec != new_sec ) {
        log_printf( &logger, "  Date      : %.2d-%.2d-%.2d\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;
        Delay_ms ( 10 );

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

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

Note

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

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

Barometer 2 click

5

Barometer 2 Click is a digital barometer on a Click board. Barometer 2 is equipped with the LPS35HW, an absolute piezoresistive pressure sensor with ceramic, water resistant package, manufactured using a proprietary technology.

[Learn More]

UVC Light click

0

UVC Light Click is Click board™ with ultraviolet LEDs with 275nm wavelength which can be complemented with UVC Click for measuring exact dose of UV radiation. UVC radiation refers to wavelengths shorter than 280 nm. Because of the spectral sensitivity of DNA, only the UVC region demonstrates significant germicidal properties. As evident by multiple research studies and reports, when biological organisms are exposed to deep UV light in the range of 200 nm to 300 nm it is absorbed by DNA, RNA, and proteins. With two 0.7W (1.4W combined power) UVC Light Click is a perfect solution as a small surface disinfection tool.

[Learn More]

Compass 3 click

5

Compass 3 Click features MMC5883MA, a complete 3-axis magnetic sensor with on-chip signal processing and integrated I2C bus suitable for use in various applications.

[Learn More]