This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Concerto dual core variable declaration

Hallo.

I have a question about Concerto variable declaration.

We have a CANopen driver and have a number of variables for M35 and C28 cores. I need to have an access to any of these variables via CAN. So I have to declare all C28 variables in the M35 core to include them into CANopen dictionary file.

Is there any simple method to do so?

PS:

Today I have found some solutions.

The first one is to declare all variables of C28 in a huge struct and place it via PRAGMA to the shared memory. Then to declare the same struct in M35 memory. But there will be problems with some existing software modules where global variables already declared inside the module. They have to be rewritten to indirect addressing mode or rewritten for new variable names.

The second solution is to make a program that converts .map-file of C28 project into the file for M35 with pointers declarations. The problem is that I have to remember to convert this file every time I insert or delete variables to C28 project.

What do you recomend to do?

 

 

 

 

 

  • We have the same question.

  • Hello,

    I believe a solution to your issue could be to define the struct in both the C28 and M3 projects, then declare pointers to the structs in each project whose value is a common location in the shared memory. 

    For example on the C28 side:

    //CTOM MSG RAM offsets for passing data

    #define C28_MTOC_PASSMSG  0x0003FC00

    // Variables that need to shared with C28x and M3
    // m3 owned memory region
    struct MtoC_Message {
    unsigned short var1;
    unsigned short var2;
    unsigned short var3;
    };

    volatile struct MtoC_Message *sharedData = (void *)C28_MTOC_PASSMSG;

    On the M3 side:

    // MTOC MSG RAM offsets for passing data

    #define M3_MTOC_PASSMSG 0x2007F800 

    // Variables that need to shared with C28x and M3
    // m3 owned memory region
    struct MtoC_Message {
    unsigned short var1;
    unsigned short var2;
    unsigned short var3;
    };

    volatile struct MtoC_Message *sharedData = (void *)M3_MTOC_PASSMSG;

    From there you should be able to access the variables from each side using the respective pointer variables. I don't think that those are the correct address values for the message RAM on an M35 device, but you should be able to apply the same principle. 

    If this does not help please clarify your statement 'there will be problems with some existing software modules where global variables already declared inside the module.'

    Regards,

    Benjamin