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.

Compiler/TMS320F28377D: CCS 10, Compiler 20.2.2 memcpy parameter

Part Number: TMS320F28377D

Tool/software: TI C/C++ Compiler

Hello,

I  wonder if someone can clarify this issue for me, please. 

I noticed that this is the declaration of memcpy in string.h of the compiler 20.2.2:  _CODE_ACCESS void *memcpy(void * __restrict s1, const void * __restrict s2, size_t n);

For ramfuncs, I found that I cannot call it this way:  

memcpy((void*)&RamfuncsRunStart, (void*)&RamfuncsLoadStart, (size_t)RamfuncsLoadSize);

but I need to call it:

memcpy((void*)&RamfuncsRunStart, (void*)&RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

Note the & before RamfuncsLoadSize.

Then I noticed in PieCtrl.c, from one of the lab exercises it has the following:

memcpy((uint16_t *)&PieVectTable+6, (uint16_t *)&PieVectTableInit+6, 448-6);

The size should be the address or a literal?  I would expect that I do not need to dereference RamfuncsLoadSize and typecast it to size_t.  When I step through using the debugger, the one with & is the correct one, but I am wondering about PieCtrl.c now.

Thank you.

  • Please understand that this ...

    Stefani said:
    memcpy((uint16_t *)&PieVectTable+6, (uint16_t *)&PieVectTableInit+6, 448-6);

    ... is a typical call to mempcy.  This ...

    Stefani said:

    memcpy((void*)&RamfuncsRunStart, (void*)&RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);

    Note the & before RamfuncsLoadSize.

    ... is the unusual case.  What's unusual?  All of those symbols are defined in the linker command file with code similar to ...

           .TI.ramfunc : {} LOAD = FLASH_APP,
                            RUN = RAMLS0 | RAMLS1 | RAMLS2 |RAMLS3,
                            LOAD_START(_RamfuncsLoadStart),
                            LOAD_SIZE(_RamfuncsLoadSize),
                            LOAD_END(_RamfuncsLoadEnd),
                            RUN_START(_RamfuncsRunStart),
                            RUN_SIZE(_RamfuncsRunSize),
                            RUN_END(_RamfuncsRunEnd),
                            ALIGN(8)

    Symbols defined in the linker command file are not like other symbols, and the C code to access these symbols is unusual as a result.  For all the details, please search the C28x assembly tools manual for the sub-chapter titled Using Linker Symbols in C/C++ Applications.

    Thanks and regards,

    -George

  • Thank you for the explanation George!  

    Stefani