Shared Memory Module

This module provides a Shared Memory Service which allow other service to exchange data asynchronously without blocking. For example the Positin feedback service write the position to the Shared memory and the Motorcontrol service can read it later without being blocked by the Positin feedback service. The Shared Memory Service is also a distributable task so it doesn’t need a core and it is actually run by the calling task (if all calling task are runnig on the same tile).

How to use


We assume that you are using SOMANET Base and your app includes the required board support files for your SOMANET device.

  1. First, add all the SOMANET Motor Control Library modules to your app Makefile.

    USED_MODULES = lib_bldc_torque_control module_board-support module_shared_memory


    Not all modules will be required, but when building an application it is recommended to include always all the listed modules. It will help to solve internal dependency issues.

  2. Include shared_memory.h header file.

  3. Instantiate the interfaces for the shared memory, you need to specify the maximum number of clients.

  4. Instantiate the service, you need to specify the maximum number of clients. You also need to put the [[distribute]] instruction.

  5. Then you can use client interface call to write or read data to the shared memory.

    #include <CoreC2X.bsp>                          //Board Support file for SOMANET Core C2X device
    #include <Drive1000-rev-c4.bsp>     //Board Support file for SOMANET Drive module
                                        //(select your board support files according to your device)
    // 2. Include the header **shared_memory.h** in your app.
    #include <shared_memory.h>
    // 3.Instantiate the interfaces for the shared memory
    interface shared_memory_interface i_shared_memory[2];
    int main(void)
            on tile[IF2_TILE]: par
                par {
                    // 4. Instantiate the service, you need to specify the maximum number of clients.
                    [[distribute]] shared_memory_service(i_shared_memory, 2);
                    //write data
                    i_shared_memory[0].write_angle(1000, 0, 0, 0, 0);
                    //read data
                    UpstreamControlData upstream_control_data;
                    upstream_control_data = i_shared_memory>[1].read()
        return 0;



[[distributable]] void shared_memory_service(server interface shared_memory_interface i_shared_memory[n], unsigned n)

Service to exchange data between tasks OF THE SAME TILE without blocking tasks execution.

  • Array – of communication interfaces to handle n different clients
  • Number – of supported client interfaces



doxygenclass: Cannot find class “shared_memory_interface” in doxygen xml output