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.

Migrating from IAR to CCE3, __segment_begin() replacement



Hi!

We have decided to migrate from IAR v3.42 to CCE v3.1. I am actually using CCE3 build  v3.2.4.3.8 on MSP430F5348 compiling with the options to enable the 20bit mode:  --silicon_version msp430x, --large_memory_model.

I need to inizialize the HEAP section at runtime, with IAR I used to write:

#pragma segment = "DATA20_HEAP"

unsigned char*  heap_start;
unsigned char*  heap_end;
unsigned int    heap_size;

int main(void)

{  heap_start = __segment_begin("DATA20_HEAP");
   heap_end = __segment_end("DATA20_HEAP");
   heap_size = heap_end - heap_start;
   memset(heap_start, 0x00, heap_size);
}


With CCE I tried to edit the linker .cmd file adding fill = 0x00 at the .sysmem segment

SECTIONS
{   ...
    .sysmem    : {} > RAM, fill = 0x00     /* DYNAMIC MEMORY ALLOCATION AREA    */   
   ...
}

but when I start the debugger I get the error:

and then I can't start the debug session.

Apart this method at compile time, which seems not working, is there any replacement to the IAR functions

__segment_begin() and __segment_end()?

I tried to find a solution reading all the application notes available on TI.com without success.

Thank you in advance.

 

  • Hi,

    unfortunately, not all IAR #pragma's were available with CCE! As far as I know there is no direct replacement for __segment_begin()  and __segment_end(). Maybe we will see it with the release of CCEv4.

    Rgds
    G**buster 

  • The functionality similar to __segment_begin() and __segment_end() can be achieved with CCE by using linker operators to get the start address, send address and size of sections. The linker operators are documented in the MSP430 Assembly Language Tools Users Guide, Section 7.13.7, http://www-s.ti.com/sc/techlit/slau131

    So if you had a user defined code or data section (which can be created using #pragma CODE_SECTION or #pragma DATA_SECTION), you can use the linker operators to define symbols for start and end address of the section, and then reference that within your C code. However, you will not be able to directly use it with the .sysmem section since this heap space is dynamically allocated at runtime, so the start and end address are not known at link time. You could potentially fill a portion of RAM with a known value (by adding the fill option to the MEMORY directive), and after running the program determine how much heap was used by checking the modified memory addresses.

     

  • Hi,

     

    I am porting over IAR code to CCS Version: 4.1.3.00038. Can you please let me know if there is some way in CCS 4.0 to find the beginning and end of .stack ?

     

    In IAR the code used for beginiing and end of CSTACK is  __segment_begin("CSTACK"))) and __segment_end("CSTACK"))-1) respectively

     

    Thanks,

    Prapti

**Attention** This is a public forum