cgsl_0411: Access nonvolatile memory - MATLAB & Simulink (original) (raw)

Main Content

ID: Title cgsl_0411: Access nonvolatile memory
Description To access target platform nonvolatile memory, use one of these approaches:
A Use a persistency service interface for asynchronous or synchronous memory access: Configure a measurement service interface that specifiesPersistent Data.Configure states and data stores to use the measurement service interface for persistent data.
B Use Initialize Function and Terminate Function blocks and theDirect Access data communication method for synchronous memory access: At the root-level of the component, use the Initialize Function block to read data and the Terminate Function block to write data.Configure the root-level ports to use the Direct Access data communication method.
Notes Memory access using a persistency service interfaceFor accessing nonvolatile memory by using a service provided by the target environment, map internal states and data stores to a measurement service interface for persistent data. For more information, see cgsl_0414: Configure service interface for component model.Alternatively, you can use a client-server interface approach for modeling the service interface. With this approach, you represent the target environment service that provides access to nonvolatile memory by using a Simulink Function block and access the service by using the Function Caller block. For more information, see Nonvolatile Memory Interfaces (Embedded Coder).Memory access by using Initialize Function and Terminate Function blocksFor synchronous accesses of nonvolatile memory during function execution, see guidelines cgsl_0406: Data send for component deployment andcgsl_0405: Data receive for component deployment.
Rationale A Memory access using a persistency service interface: Supports asynchronous or synchronous reading and writing to nonvolatile memoryRobustly handles data accesses of functions that execute concurrentlySupports multiple instances of componentsUses target platform service
B Memory access using Initialize Function and Terminate Function blocks: Supports only synchronous reading and writing to nonvolatile memoryRobustly handles data accesses of functions that execute concurrentlySupports multiple instances of components
Model Advisor Check A Model Advisor check is not provided for this guideline.
Examples Memory access using a persistency service interface Simulink model that contains a discrete integratorCode Mappings editor. The Discrete Integrator state is mapped to PermanentRAM measurement service.Example of generated_ModelName_.h:#include "PersistencyServiceExample_types.h" #include "services.h" . . . /* Storage class 'PersistentMemory' */ extern double DiscreteIntegrator; . . .Example of generated_ModelName_.c:#include "PersistencyServiceExample.h" /* Storage class 'PersistentMemory' */ double DiscreteIntegrator; /* '/Discrete Integrator' */ . . . void PersistencyServiceExample_step(void) { double EstimatedPosition; EstimatedPosition = DiscreteIntegrator; DiscreteIntegrator++; . . . }Memory access using Initialize Function and Terminate Function blocksSimulink model that uses Initialize Function and Terminate Function blocks to access nonvolatile memoryExample of generated_ModelName_.c:void CD_initialize(void) . . . &(get_CD_initialize_input())[0] . . . void CD_terminate(void) { memcpy(&(getref_CD_terminate_OutBus_NVM()))[0]... }

Version History