2010-07-30 02:29 AM
Dynamic memory allocation using cosmic compiler
2011-05-17 06:09 AM
2011-05-17 06:09 AM
Hi ubiali,
Ah ok ! Thanks ubiali for this ultra fast reply ! With regards, MCU Lüfter2011-05-17 06:09 AM
Hi ubiali,
In my application I need to allocate memory space with malloc and I have tried to set the heap zone to 1KB but I couldn't. I have updated the lkf file as following: # Defines - section reserved for STVD #<BEGIN DEFINED_VARIABLES> +def __startmem=@.bss +spc .bss=0x400 # reserve 1K space +def __endmem=0x7ff +def __stack=0xfff #<END DEFINED_VARIABLES> But I got the following error message: #error clnk Debug\project.lkf:1 segment .bss size overflow (807) How can I enjoy using my heap space and get rid of this error message. Perhaps that I am using a huge global variables but how can I find it ? BTW, what does mean ''+def __endmem=0x7ff and +def __stack=0xfff'' ? Does it mean that stack zone is : 0x800 ---> 0xfff and the user zone is 0x000 --> 0x7ff ? Thanks and regards, MCU Lüfter2011-05-17 06:09 AM
2011-05-17 06:09 AM
Hi ubiali,
Thereafter a copy of my lkf file: ----------------------------------------------------------------------------------------------------------- #<BEGIN SEGMENT_CONF> # Segment Code,Constants: +seg .const -b 0x8080 -m 0xff80 -n .const -it +seg .text -a .const -n .text # Segment Eeprom: +seg .eeprom -b 0x1000 -m 0x800 -n .eeprom # Segment Zero Page: +seg .bsct -b 0x0 -m 0x100 -n .bsct +seg .ubsct -a .bsct -n .ubsct +seg .bit -a .ubsct -n .bit -id +seg .share -a .bit -n .share -is # Segment Ram: +seg .data -b 0x100 -m 0x700 -n .data +seg .bss -a .data -n .bss #<END SEGMENT_CONF> ----------------------------------------------------------------------------------------------------------- Thanks for each explanation ! Best regards, MCU Lüfter2011-05-17 06:09 AM
''+seg .data -b 0x100 -m 0xD00 -n .data''
means that the data+bss segments (because they are attached to each other with the -a option) start in 0x100 for a maximum size of 0xD00 (-> the max address is 0xE00). Note that your bss segment now also contains the heap, that will thefore be within this address range as well.2011-05-17 06:09 AM
2011-05-17 06:09 AM
Hi ubiali,
Thanks ubiali ! I get it working but I still need more clarification so thanks in advance. You have changed ''+seg .data -b 0x100 -m 0x700 -n .data'' by ''+seg .data -b 0x100 -m 0xD00 -n .data'' does it mean that global variables are located in zone 0x100 to 0xD00 ? Anther question: In your conclusion: ''This linker file will give you the following RAM configuration: 0x000 to 0x0FF: zero page containing @tiny variables (.bsct+.ubsct) 0x100 to 0xF00: contains @near data (.data+.bss) + 1k of heap, 0xF00 to 0xFFF : stack'' The zone from 0xD00 to 0xF00 is reserved to which type of data ? How can I enlarge the @near data + heap zone beyond 0xF00 ? Is it hardware ? In fact, I need to enlarge more the heap zone and I worry that I will overlap with stack ? How can I avoid this ? With regards, MCU Lüfter