Topic : Allocation of a memory segment

Forum : ST7/STM8

Original Post
Post Information Post
October 8, 2011 - 4:49pm
Guest

Hi,
I am using STM8S103F3. and I need to have more than 256 byte of data. I would prefer to allocate manually some data in page0 and other data in an other section starting from 0x0100 (second group of 256 byte). How can I use linker directive in C file to create and allocate a memory segment containing my variables?
Best Regards,

Fabrizio

Replies
Post Information Post
+1
0
-1
October 10, 2011 - 10:19am
Raisonance Support Team

Hi Fabrizio,

This will be a COMPILER directive, not linker:

- Activate the "DMC(data)" compiler directive. This will select the "data" mode as default memory class. All variables will in "data" mode have a 16-bit address, although "page0" variables have an 8-bit address (hence generate shorter code).
- Add the "page0" qualifer on all variables that you explicitly want to be in the 256 lower bytes.
page0 unsigned char fastcounter = 4;

This is it.

Note that if you do not want to perform this task manually, you can use the auto-relocation mode: Once your project is almost ok (compiles and links properly), activate the autoreloc through the Ride7 interface, which will locate your variables at the most efficient place depending on tits usage: The most used variabnles will get in page0, the other ones in data.

Also note that there is no speed difference between page0 and data variables on STM8. Both are equally fast, so this mechanism is useful only for code size reduction.

Best Regards,