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.

TMS320F28377D: Memory usage

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi,

Could you provide any manual about a variable in struct and memory usage?

When declare 8 float variables in struct, CLA1_MSGRAMHIGH memory usage is 100%

when declare 6 float variables in struct1, 2 float variables in struct2, it's decreased to 87%

With separating them to 3 struct, it's decreased to 75%.

Could you let me know why it's different?

Does it due to struct padding? if yes, is there any issue in compiling?

Thanks.

  • Hi David,

    The compiler could be padding bytes in order to align the struct definition. Please see the section 7.1.7 Field/Structure Alignment of the C2x Compiler guide linked here. One way to check this would be to open the CCS Memory Browser (View >> Memory Browser) and check the addresses where each of the float's variables inside the struct are being placed. 

    Are you using one of the linker cmd files from C2000ware? If so, which one?

    Best Regards,

    Delaney

  • Hi David,

    I will close this thread since we have moved over to email.

    For future e2e'rs who comes across this thread, the below were my findings:

    I did a few tests of my own matching the customers setup and I was able to replicate the with the 3 cases:

    Case 1: When declare 8 float variables in struct, CLA1_MSGRAMHIGH memory usage is 100%

    Case 2: when declare 6 float variables in struct1, 2 float variables in struct2, it's decreased to 87%

    Case 3: With separating them to 3 struct, it's decreased to 75%.

    I only see the difference in percent memory usage between the cases if there is other data being allocated to the CLA_MSGRAMHIGH memory along with the 1-3 structs (like in the customers case where they also allocate claLPF, cla1LPF, cla1Change etc. along with the structs). Without another variable allocated, each case shows identical memory usage of 50%.

    This behavior appears to be due to the fact that in case 1, the compiler needs to find a bigger continuous area of memory to place the struct, whereas with case 2 and case 3, it can split them up into different locations. The CLA_MSGRAMHIGH section of memory is relatively small, and the total data in the structs will take up 4B x 8 x 4 = 128B (no matter which case), which is half the size of the total CLA_MSGRAMHIGH memory. The images below show where the data was placed in CLA_MSGRAMHIGH from what I have observed in the Memory Browser for each of the three cases without and with another variable allocated.

     

    From what I’ve observed, just because the Memory Allocation View says a section is 100% full doesn’t always mean that more data can’t be allocated there. This percent is a representation of how much data spans the memory rather than the total amount actually written. To answer the question, having 8 separate structs each with one float (or also just having 8 separate floats) would give the compiler smaller chunks of memory that need to be allocated to continuous addresses, so it could help if they are really looking to maximize this memory. If the program tries to allocate more data than there is space for, the compiler will throw an error, so there should be no worry with writing too much.

    Best Regards,

    Delaney