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 of pointer located in CPUTOCMRAM and pointing elements in CPUTOCMRAM

Part Number: TMS320F28388D

Hello,

I have a structure with pointers initialized to point on some elements of this structure.

Here *p_in (0x0000B0A8) is pointing id (0x0000B084) and *p_set (0x0000B0AA) is pointing idRef (0x0000B0A4).

The structure is running on CPU1 and has to be shared with CM core.

For the moment the structure is located in LS6 RAM and when necessary, I copy the content of the structure into CPUTOCMRAM. Everything works well but it takes time to transfer the structure.

To improve this, I locate the structure directly into CPUTOCMRAM using #pragma DATA_SECTION macro as the memory is READ/WRITE accessible from CPU1.

When I debug, the main structure is well located in CPUTOCMRAM memory (0x39000) however the pointers are still pointing on LS6 zone instead of pointing elements in CPUTOCMRAM.

Now *p_in (0x000390A8) is pointing id@0x0000B084 instead of (0x00038084) and *p_set (0x000390AA) is pointing idRef@0x000B0A4 instead of (0x000390A4).

How can I correct this issue?

Sincerely.

Jérôme

  • Hi Jérôme,

    You will need to place the members pointed to by the pointer inside the structure to CPUTOCMRAM, For example the p_in points to a member of 'motor_foc', in this case motor_foc will also need to be placed in the CPUTOCMRAM RAM.

    Thanks,

    Ashwini

  • Hi Ashwini,

    Thanks you for your reply. For information, motor_foc is placed in CPUTOCMRAM. As you can see in the second picture all the elements are in CPUTOCMRAM. *p_in@0x000390A8, id@0x00038084, *p_set@0x000390AA and idRef@0x000390A4.

    Sincerely.

    Jérôme

  • Hi Jerome,

    I accidentally clicked on "TI thinks resolved", please ignore it.

    In the snapshot I see "motor_enc" but not "motor_foc".Can you confirm that "motor_foc" which is what is mapped to the struct is also placed on the CPU-CM shared RAM.

    Thanks,

    Ashwini

  • Hi Ashwini,

    Yes indeed, motor_foc is in CPUTOCMRAM starting @0x00039000.

  • Hi Jerome,

    Please could you look up the addresses 0xB084 and 0xB0A4 in the memory browser and check if it maps to another datastructure instacne. Maybe that instance is being linked to the datastructure?

    Thanks,

    Ashwini

  • Hi Ashwini,

    I don't know how to interpret the results when disassembling

    Here is what I have @0x0000B084.

    00b084:   0000        ITRAP0       
    00b085:   3F00        MOV          @0x0, P
    00b086:   0000        ITRAP0       
    00b087:   0000        ITRAP0       
    00b088:   0000        ITRAP0       
    00b089:   0000        ITRAP0       
    00b08a:   0000        ITRAP0       
    00b08b:   0000        ITRAP0       
    00b08c:   0000        ITRAP0      

    Here is what I have @0x0000B0A4

    00b0a4:   0343        SUBL         ACC, *-SP[3]
    00b0a5:   037A        SUBL         ACC, *-SP[58]
    00b0a6:   0243        MOVB         ACC, #67
    00b0a7:   0001        ABORTI       
    00b0a8:   0000        ITRAP0       
    00b0a9:   0000        ITRAP0       
    00b0aa:   00800343    LC           0x000343
    00b0ac:   0343        SUBL         ACC, *-SP[3]
    00b0ad:   037A        SUBL         ACC, *-SP[58]
    00b0ae:   0243        MOVB         ACC, #67
    00b0af:   0001        ABORTI       
    00b0b0:   0000        ITRAP0       
    00b0b1:   0000        ITRAP0       
    00b0b2:   00800343    LC           0x000343
    00b0b4:   0343        SUBL         ACC, *-SP[3]
    00b0b5:   037A        SUBL         ACC, *-SP[58]
    00b0b6:   0243        MOVB         ACC, #67
    00b0b7:   0001        ABORTI       
    00b0b8:   0000        ITRAP0       
    00b0b9:   0000        ITRAP0       
    00b0ba:   00800343    LC           0x000343
    00b0bc:   0343        SUBL         ACC, *-SP[3]
    00b0bd:   037A        SUBL         ACC, *-SP[58]
    00b0be:   0243        MOVB         ACC, #67
    00b0bf:   0001        ABORTI       
    00b0c0:   0000        ITRAP0       
    00b0c1:   0000        ITRAP0       
    00b0c2:   0000        ITRAP0       
    00b0c3:   3F80        MOV          *XAR0++, P
    00b0c4:   0000        ITRAP0       
    00b0c5:   4080        TBIT         *XAR0++, #0x0
    00b0c6:   0001        ABORTI      

    Starting @0xB0A0, I know that I have a structure (DRV registers structure) but there are no links with motor_FOC.

    Sincerely.

    Jérôme

  • Hi Jerome,

    Please look at address "0x0000B084" in the memory browser and not in the disassembly window.

    One other way to check if the debugger is showing incorrect value or if the structure element is indeed mapped to the 0xB084 address you can do this: in your application create a variable that saves the value (not address) of the structure elements p_in and p_set. As these are pointers, their value should be the address the pointers point to. If the values of these pointers is 0xB084 then then the application is assigning the p_set and p_in to data structure stored at 0xB084. If not, then looks like we have a debugger issues.

    Thanks,

    Ashwini

  • Hello Ashwini,

    After some investigations I have identified the main issue. In fact when the structure (motor_FOC) is located at 0xB000 there are no problems, the structure is well initialized at startup.

    0x0000B000    motor_foc
    0x0000B000    3333    3F33    825A    390C    CCF7    3912    0000    4396    D289    3ADE    CCCD    3DCC    000C    0000    7400    0000    7480    0000    7580    0000    7500
    0x0000B015    0000    0000    0000    0B00    0000    0B20    0000    0B60    0000    0B40    0000    0000    0000    0B10    0000    0B30    0000    0B70    0000    0B50    0000
    0x0000B02A    0B14    0000    0B34    0000    0B74    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    22EB
    0x0000B03F    3D95    5BA3    3F6D    0000    0000    0D82    0001    5100    0000    000C    0000    4000    469C    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B054    0000    0000    0000    0000    0000    0000    597C    45C4    0000    0000    6FDA    44F5    0000    0000    0000    0000    0000    4348    8536    3CF9    33D6
    0x0000B069    3F78    4000    471C    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    22EB    3D95    5BA3    3F6D    0000    0000
    0x0000B07E    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B093    0000    0000    0000    0000    0000    0000    41A0    6666    3F66    CCCD    3DCC    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B0A8    0000    0000    0000    0000    0000    0000    89D4    3ED7    307A    3D61    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B0BD    0000    0000    0000    307A    3EE1    307A    3D61    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B0D2    0000    0000    0000    0000    0000    0000    0000    3F80    D70A    3CA3    0000    0000    0000    0000    0000    0000    0000    4080    0000    0000    0000
    0x0000B0E7    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    3333    3F33    825A    390C    CCF7    3912    0000    4396    D289    3ADE
    0x0000B0FC    CCCD    3DCC    000C    0000    7400    0000    7480    0000    7580    0000    7500    0000    0000    0000    0B00    0000    0B20    0000    0B60    0000    0B40
    0x0000B111    0000    0000    0000    0B12    0000    0B32    0000    0B72    0000    0B50    0000    0B16    0000    0B36    0000    0B76    0000    0000    0000    0000    0000
    0x0000B126    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    22EB    3D95    5BA3    3F6D    0000    0000    0D8A    0001    5140    0000    000C
    0x0000B13B    0000    4000    469C    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    597C    45C4    0000    0000
    0x0000B150    6FDA    44F5    0000    0000    0000    0000    0000    4348    8536    3CF9    33D6    3F78    4000    471C    0000    0000    0000    0000    0000    0000    0000
    0x0000B165    0000    0000    0000    0000    0000    22EB    3D95    5BA3    3F6D    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B17A    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    41A0    6666    3F66    CCCD
    0x0000B18F    3DCC    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    89D4    3ED7    307A    3D61
    0x0000B1A4    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    307A    3EE1    307A    3D61    0000    0000    0000
    0x0000B1B9    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    3F80    D70A    3CA3
    0x0000B1CE    0000    0000    0000    0000    0000    0000    0000    4080    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0000B1E3    0000

    But when I declare it in MSG CPU to CM memory (0x39000) using pragma (#pragma DATA_SECTION(motor_foc, "MSGRAM_CPU_TO_CM");), the structure is not initialized at all.

    0x00039000    motor_foc
    0x00039000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039015    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003902A    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003903F    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039054    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039069    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003907E    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039093    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000390A8    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000390BD    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000390D2    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000390E7    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000390FC    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039111    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039126    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003913B    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039150    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x00039165    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003917A    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x0003918F    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000391A4    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000391B9    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000391CE    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000391E3    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000    0000
    0x000391F8    0000    0000    0000    0000    0000    0000    0000    0000

    Here is how I create and initialize my structure :

    #pragma DATA_SECTION(motor_foc, "MSGRAM_CPU_TO_CM");
    static FOC_STRUCT motor_foc[] =
    {
     {
      //--- MOTOR_1 ---------------------------------------------------------------
      //--- MOTOR PARAMS STRUCTURE ------------------------------------------------
      .motor_cfg.Rs                         = (float32_t)MOTOR1_RS,
      .motor_cfg.Ld                         = (float32_t)MOTOR1_LD,
      .motor_cfg.Lq                         = (float32_t)MOTOR1_LQ,
      .motor_cfg.kv                         = (float32_t)MOTOR1_KV,
      .motor_cfg.ke                         = (float32_t)MOTOR1_KE,
      .motor_cfg.ki                         = (float32_t)MOTOR1_KI,
      .motor_cfg.polePairs                  = (float32_t)MOTOR1_POLES_PAIRS,
      //--- MOTOR ACQUISITION STRUCTURE -------------------------------------------
      .motor_acq.p_adcRegs[0]               = MOTOR12_IVA_ADC_REGS,
      .motor_acq.p_adcRegs[1]               = MOTOR12_IVB_ADC_REGS,
      .motor_acq.p_adcRegs[2]               = MOTOR12_IVC_ADC_REGS,
      .motor_acq.p_adcRegs[3]               = MOTOR12_VBUS_ADC_REGS,
      .motor_acq.p_adcResultRegs[0]         = MOTOR12_IVA_ADC_RESULT_REGS,
      .motor_acq.p_adcResultRegs[1]         = MOTOR12_IVB_ADC_RESULT_REGS,
      .motor_acq.p_adcResultRegs[2]         = MOTOR12_IVC_ADC_RESULT_REGS,
      .motor_acq.p_adcResultRegs[3]         = MOTOR12_VBUS_ADC_RESULT_REGS,
      .motor_acq.p_vaMeasReg                = (volatile uint16_t *)(MOTOR1_VA_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_vbMeasReg                = (volatile uint16_t *)(MOTOR1_VB_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_vcMeasReg                = (volatile uint16_t *)(MOTOR1_VC_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_vBusMeasReg              = (volatile uint16_t *)(MOTOR12_VBUS_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_iaMeasReg                = (volatile int16_t *)(MOTOR1_IA_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_ibMeasReg                = (volatile int16_t *)(MOTOR1_IB_ADC_PPB_RESULT_ADDR),
      .motor_acq.p_icMeasReg                = (volatile int16_t *)(MOTOR1_IC_ADC_PPB_RESULT_ADDR),

    ....

  • Finally I found the issue.

    It is indeed a problem of startup initialization.

    In my "2838x_RAM_lnk_cpu1.cmd" I have at the end of the file "MSGRAM_CPU_TO_CM   > CPUTOCMRAM, type=NOINIT"

    Removing "type=NOINIT" solved my issue. The structure is now well initialized and the pointers too.

    Jérôme