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.

TMS320F28388D: Problem with IPC MSG share RAM CM - CPU2 core

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

Hi, 

I am working on project which is using MCU F28388D, My project is used with all 3 cores of MCU. 

Currently , I am using SDK: C2000Ware_MotorControl_SDK_3_00_01_00 (with C2000ware Version: 3.02.00.00 inside),   CCS v 9.3.0.00012 with compiler for C2000 C28x: Ti v18.12.4.LTS and Arm core: Ti V18.12.4.LTS

With first test:

 - I define struct data in IPC MSG SHARED RAM CM to CPU2   in both CM and CPU2 picture below:

   In CM core  I declare the variable  sram_cm_to_cpu2, and in CPU2 core I declare the variable ipcCMToCPU2Data with struct data below (both sram_cm_to_cpu2 and ipcCMToCPU2Data is assigned in IPC MSG RAM CM to CPU2 with #pragma DATA_SECTION...)

I debug project and check memory browser (picture below) in CCS, everthing is ok, data can transfer nomarly from CM - CPU2:

But with my second test, I only change in struct data from Buff_data_cpu2[12] to Buff_data_cpu2[13] like picture below:

The problem occurs, data can not tranfers correctly from CM -> CPU2, I check memory map in memory browser picture below:

In Cm core maybe everything is still normal, but in CPU2 I don't know why the IPC_CPU_To_CM_GetBuffer size is increase till 192 words(384 byte), I have checked it in driverlib code ipc.c, It is declared with struct which has size 136 words(272 bytes)  like memory map shows in picture of first test.

I don't know why the reason? Can you help me to solve this problem, because with my project I have to increase the array Buff_data_cpu2 > 12 elements.

CMD file for 2 core below:

Thanks,

Longpt

  • I am sorry for CMD picture I underline wrong with CPU2 cmd file (CMTOCPURAM instead of CMTOCPURAM_ECAT)

  • Longpt,

    Did you make any changes to ipc.h and ipc.c driverlib files?

    The size of IPC_CPU_To_CM_GetBuffer depends upon the definitions in ipc.h. Also, it is not clear from your post between the relationship between sram_cm_to_cpu2 and ipcCMToCPU2Data  to IPC_CPU_To_CM_GetBuffer ? Answering the question should resolve the issue.

    typedef struct
    {
        uint32_t command;
        uint32_t address;
        uint32_t dataw1;
        uint32_t dataw2;
    }IPC_Message_t;

    typedef struct
    {
        IPC_Message_t Buffer[IPC_NUM_OF_INTERRUPTS][IPC_BUFFER_SIZE];
        uint16_t      GetWriteIndex[IPC_NUM_OF_INTERRUPTS];
        uint16_t      PutReadIndex[IPC_NUM_OF_INTERRUPTS];
    }IPC_GetBuffer_t;

    Regards,

    Manoj

  • Manoj,

    I don't change any thing in ipc.h and ipc.c driverlibs file?

     "Also, it is not clear from your post between the relationship between sram_cm_to_cpu2 and ipcCMToCPU2Data  to IPC_CPU_To_CM_GetBuffer "

    I make clear source for CPU2 and CM that I declare a struct data with purpose is transferring data between CPU2 and CM core through IPC SHARE RAM CM and CPU2, detail below:

    -  In CM code: I declare s struct named sram_cm_to_cpu2 then assign it to shared ram by DATA_SECTION.... like picture below:

    In CPU2 code , the same with CM code , I declare a struct named ipcCMToCPU2Data then assign it to shared ram by DATA_SECTION.... like picture below: (you can see the  defined struct in CPU2 has diferrent name with struct in CM but they has the same structure) :

    About IPC_CPU_To_CM_GetBuffer  , I see that in ipc.c , they are also assigned to IPC MSG Shared RAM between cores like pictures below:

     With the array buff_data_cpu2 in defined struct, When I change the elements <=12, everything may be ok as you can see in picture in previous post - first test.But I change the elements >12 in both CPU code , the problem occurs like picture in second test. That make data that is written in CM Core can not be read in CPU2.

    Longpt

  • I am sorry , the picture in CPU2 code , the struct does not has the field Done_send inside, I put the right picture again below:

  • Long Pham,

    I was unsuccessful in re-creating this problem from my end. For me, CPU to CM Get Buffer always takes only 136 words as expected. It doesn't increase in size like what you are seeing. I tried this by assigning an array to the same data section. For me changing the array size doesn't affect size of Get Buffer.

    Based on your snapshot, it looks to me that address 0x38088 -0x38095 still seems to have the right content. (all 0xFFFF). May be try sending different value and see whether you receive the right content from CM side?

    Regards,

    Manoj

  • Manoj,

    "Based on your snapshot, it looks to me that address 0x38088 -0x38095 still seems to have the right content. (all 0xFFFF). May be try sending different value and see whether you receive the right content from CM side?"

    ---> Yes, You are right , From  address 0x38088 have the right content, I have tried different values, and with CPU2 from address 0x38088 the values change like I change from CM side. But in CPU2 by somehow, It assigned the  ipcCMToCPU2Data  from address 0x380C0 that make all datas are read as zero like snapshot. I also check size by sizeof of IPC CPU To CM Get Buffer from CPU2, It still returns 136 words nomarlly.

    By the way I also check the data that send from CPU2 to CM (In my project there are both data transfer from CM to CPU2 and CPU2 to CM), I see that It has the same problem, I declared a shared struct for CPU2 to CM data and assigned it to share ram defined in cmd file from shared CPU2TOCM RAM0 from address 0x39000, If I change the size of shared data to a some  limit size. It also assigned wrong address maybe sometime for  shared data or sometime for IPC_CPU_TO_CM Put buffer( in case put the wrong address for IPC_CPU_TO_CM Put buffer I still can send and receive the right data from CU2 to CM but basically It somehow hard to understand). --> I dont know whether my compiler  or SDK , driverlib version that I am using , Is there some bugs??

    Temporarily, I fixed this problem by assigning my own shared data to CPU2TOCMRAM1 (0x39400) and CMTOCPU2RAM1(0x38400) not use the same RAM0 (0x38000 and 0x39000) which driverlib CPU2 use for IPC CPU TO CM PUT and GET Buffer. Everything may be ok.

    But I still want to find out the root core of the problem.

    Regard,

    longpt

  • It also assigned wrong address maybe sometime for  shared data or sometime for IPC_CPU_TO_CM Put buffer( in case put the wrong address for IPC_CPU_TO_CM Put buffer I still can send and receive the right data from CU2 to CM but basically It somehow hard to understand). --> I dont know whether my compiler  or SDK , driverlib version that I am using , Is there some bugs??

    It is good to know that sizeof IPC CPU To CM Get Buffer from CPU2 is 136 words. So it is clear that the linker didn't place ipcCMToCPU2Data  array immediately after 136 words. That is the reason why you are seeing this problem. You can't say this as a bug as the linker has the prerogative to put variables anywhere in the memory assigned.

    CM core is byte addressable and C28x core is not.

    In CM core, in a given memory location, 1 byte is stored

    In C28x core, in a given memory location, 1 word ( 16 bits) are stored.

    This is the reason why data written in 0x20086110 is available in 0x38088.

    0x20086110- 0x20086000 = 0x110. If you divide 0x110/2, you get 0x88.

    So, if you want to be read data from 0x380C0 (address of ipcCMToCPU2Data, you need to write to 0x20086180

    Regards,

    Manoj

  • So it is clear that the linker didn't place ipcCMToCPU2Data  array immediately after 136 words. That is the reason why you are seeing this problem. You can't say this as a bug as the linker has the prerogative to put variables anywhere in the memory assigned.

    --> ok, As you said everytime when I declare shared data between CPUs by shared ram, I have to check the address that linker assigns it into shared ram then assign it into correct address if there is the mismatch? I think It is quite inconvenience.

  • Long Pham,

    Executing this command should perform the address correction automatically for you

    IPC_readMessageFromQueue(IPC_CM_L_CPU2_R, &messageQueue, IPC_ADDR_CORRECTION_ENABLE,
                                 &RxMsg, IPC_NONBLOCKING_CALL);

    RxMsg.address should have the starting address of received message. Please check ipc_ex2_msgqueue_c28x1 and ipc_ex2_msgqueue_cm C2000Ware example to understand how all this works.

    Regards,

    Manoj