Main Content

Nonvolatile Memory Interfaces

Typically, a component accesses nonvolatile memory during component startup or shutdown. Within a platform environment, a component can gain access to nonvolatile memory directly or by using a nonvolatile memory service.

Nonvolatile Memory Direct Access Interfaces

To gain access to nonvolatile memory directly, without using a platform service, and configure the relevant data elements for code generation:

  1. In the component model:

    • Represent a direct memory read with an inport (Inport or In Bus Element block) connected to an Initialize Function block.

    • Represent a direct memory write with an outport (Outport or Out Bus Element block) connected to a Terminate Function block.

  2. If the nonvolatile memory data access occurs during function execution, connect a safeguard block to root-level inport or outport as described in Receive and Send Communication Interfaces.

  3. If you have not already done so, open the Embedded Coder app.

  4. In the Code Mappings editor, configure the code interfaces for the inport and outport that are connected to the Initialize Function and Terminate Function blocks. At a minimum, set these properties:

    • Storage Class, which controls the appearance and placement of the signal data in the generated code.

    • Identifier, which names the model element in the generated code. The code generator uses the identifier in names constructed for access functions.

    • GetFunction or SetFunction, which specifies the naming rule for the name of the platform get or set method that handles the read or write operation

    Set Storage Class to GetSet.

    For more information about the GetSet storage class, see Choose Storage Class for Controlling Data Representation in Generated Code.

  5. In the Code Mappings editor or by using the code mappings programming interface, configure the prototypes for the initialize and terminate entry-point functions. For more information, see Configure Generated C Function Interface for Model Entry-Point Functions.

Nonvolatile Memory Service Interfaces

To represent use of a platform nonvolatile memory service in a component model and configure the relevant data elements for code generation:

  1. In the model:

    • Represent the platform service by using a Simulink Function block.

    • Access the service by using a Function Caller block.

  2. Configure the function prototype generated for the blocks to align with platform requirements by using the Code Mappings editor or the code mappings programming interface. See Configure Entry-Point Function Interfaces for Simulink Function and Function Caller Blocks.

See Also

| | | | | | |

Related Topics