2017-06-14 02:58 AM
Currently I have an issue when trying to allocate a structure to RAM.
The issue I have is that my structure occupies a total of 373 bytes but the compiler/linker is insistent on trying to locate this structure in the zero page (first 256 bytes). To enable compilation I have reduced the size of the structure to allow for viewing of the map file to see where the compiler is allocating this data.
I have attempted to use the pragma directives to allocate this structure to the @near range, which would allow anywhere within the RAM space. This again gave me a section overflow of the zero page!
To go one step further I have defined my own section within the RAM space with the required size memory allocation. I have positioned this directly after the zero page and prior to the .data section. Using absolute addressing and the pragma directives I am still experiencing the same issues, or, now I have an error as the symbol has been defined for the zero page. I have e-mailed Cosmic but they don't seem to care for offering support.Has anyone got any advice?
UPDATE: Just to add some further information.
- RAM size = 1024 bytes.
- Zero Page = 256 bytes.
- Max stack size 513 bytes (my thoughts are that this will be given the optimal size by the compiler/linker depending in the .data and .bss usage).
- Default linker file is being used, with the exception of the test section described above.
#ram #stm8 #cosmic #cosmic-stm8-cosmic-lkfSolved! Go to Solution.
2017-06-14 09:26 AM
Hello,
in order to put your structure (or any other variable) in the @near address space (out of page zero), you either have to specify the @near attribute for you structure or to use a memory model where this attribute is the default (+modsl0 is the usual choice for this).
If neither of these solutions seem to work please post your code here and I'll see what is wrong with it (I will also check with my colleagues if they have received your email on the support address).
Regards,
Luca
2017-06-14 09:26 AM
Hello,
in order to put your structure (or any other variable) in the @near address space (out of page zero), you either have to specify the @near attribute for you structure or to use a memory model where this attribute is the default (+modsl0 is the usual choice for this).
If neither of these solutions seem to work please post your code here and I'll see what is wrong with it (I will also check with my colleagues if they have received your email on the support address).
Regards,
Luca
2017-06-15 02:48 AM
Hi Luca,
Thanks for your response! A member of the Cosmic support team has now been in contact with me.
I have tried to use the space modifier, however, I am returned with a space attribute conflict error. Similarly this happens when using the pragma directives also. I will look at modifying the default memory model.
Thanks again,
Aaron
2017-06-15 02:56 AM
I have modified the default configuration file to use the stack long memory model and that has compiled first time and allocated my structure in the .data section as desired!
Thank you very much for your help!
Aaron
2017-10-26 01:38 AM
Dear Aaron, could you please be so kind and tell me how you have done this?
2017-10-26 03:17 AM
Hi Klaus,
After speaking with COSMIC it became apparent that I was using the incorrect memory model.
In the STVD environment the memory model settings can be altered under Project Settings -> C Compiler -> Memory Models and select short stack. Then when declaring the structure I have used the @near identifier.
There are a number of other ways that this can be done, for example defining your own linker file and start-up program. Hope this helps.2017-10-30 07:36 AM
Hi Aaron,
yes it looks as there are some wrong default values. I solved my problem this way:
Project -> Settings -> Linker -> Input. The RAM end value should be 0x3FF, but was 0x1FF.
Then I spread my variables using the @tiny and @near attributes.
Now facing the next problem: suddenly my constants are placed in the address range 0xFFE0 to 0x10060. These addresses do not exist in the flash STM8S103 (and are not defined with above settings).
As there seem to be faulty data for the address ranges, where can I find the default definitions for the address ranges? Is this in .h or .ini files, is it with Cosmic or with STVD?
Thanks, Klaus
2017-10-30 07:53 AM
Klaus,
I would suggest some further contemplation before redefing your RAM space. The reason your 'RAM' doesn't end at the correct address is because there is an allowance in RAM for your stack which starts at 0x3FF and decrements down as items are added i.e. when you stored variables etc during function calls. As long as you are aware of this and handle it accordingly then you should have no issues.
Also, as a quick side note you should read the corresponding compiler documentation to ascertain whether or not you need to modify the linker file and what consequences this will have on your desired process.
In order to obtain your address ranges I would refer back to the correct datasheet. Providing you are using the STM8S003F3 then it can be found
.Hope this helps,
Aaron