How and when to use NvM_WriteBlock?

The API NvM_WriteBlock is used to persist user data into a Non volatile memory for use-cases which requires that data must be written immediately on request. EEPROM and (D)FLASH emulation are examples for non volatile memory.

For correct and consistent operation, The communication between application(SW-C) and NvM must follow a defined sequence of steps.

  1. Application gets the reference to a RAM block corresponding to a NVRAM block. Typically each block is organized as C structure. Rte provides a interface function to get a reference to this RAM block.
  2. Application update RAM variables as required and prevent any further update to this RAM block.
  3. Application issues NvM_WriteBlock using RTE interface corresponding block. This function returns E_OK when write request is placed to job queue, otherwise an error value is returned.
  4. Once write request is accepted, application must prevent any update to the RAM structure.
  5. It is the responsibility of application to poll the status of the write job using API NvM_GetErrorStatus. Notable status are NVM_REQ_PENDING ( means write in progress ), NVM_REQ_OK (write job completed successfully) and any other error reporting failure.
  6. The application must continue to poll the job status until the API NvM_GetErrorStatus returns NVM_REQ_OK or an error.

An example

Assume that there is a block named SpeedLimiter. It has two uint8 data fields 1. defaultLimit, maxLimit. Also assume that that SW-C runable is called cyclically. The pseudocode for state-machine based implementation available in my github repository here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Jayakumar Sengottuvel
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.