2008-09-14 09:15 PM
Data/SRAM Segment problem help~~
2011-05-17 03:44 AM
Thank you very much Ivanov-i and Lanchon.
Besides changing the physical mcu chip, is that any program skill/technique to work around this problem? As I need a total of variables more than 64kbytes, which exceeded the RAM size of mcu chip version E. or Is that anyway to place the variable in data segment since it has 128kbytes? Like what lanchon said, using constant? Sorry if i'm asking stupid question. I'm new in embedded design.. [ This message was edited by: suyongyao on 11-09-2008 06:47 ]2011-05-17 03:44 AM
Hi Suyongyao,
First, if you have in your program values, which never change (constants) you could declare them with ''const'' qualifier, for example: const float a[75] = {1, 2, 3, and so on..}; In this way the linker will put them in the Flash. However, I suppose that this is not your case. You should be aware that in STM32 (like many other embedded CPUs) a large amouth of memory is Flash and smaller part is RAM. You can not alter the Flash - at least not at the speed of the RAM. So, you can not put variables there. The only software tricks, which you could use in this case is to limit the number of the variables you use or their size. This hardly depends on the algorithm you implement, but few guidelines are: - reusing of temporary variables; - modifying the algorithm to work over a part of the data (i.e. if it is possible to use an array of [75] instead of [75][75]); - using variables of smaller size (''short'' or ''char'' instead ''float''). If nothing of this could be used you should use an external RAM. I think than C, D and E devices allow this. You should additionaly modify the linker file (.xcl or .icf) to force it to put all or part of your variables there. Be aware that the access to the external RAM is considerably slower than to the internal one. BR, Ivan2011-05-17 03:44 AM
Hi,
You've asked me what the BSS section is. Explanation will be too long to present it on forum. Please read about the linker. What I can tell you is that if you have RAM memory e.g. 20kB, this 20kB is divided in to sections. Compiler has to know to what range of addresses it can place the variables and stack. Example. Place .stack form 0-10kB and .bss form 10kB-20kB. What is important. When you declare variable before main and did not initialize by eg. zero it will be in .bss section.Code:
int i; main(){ } The pointer of i will point the address of (0x200000 + 10KB) which is first byte of .bss section. I hope it will give you first step to learn about linker. This was just an example don't take it seriously try to find *.ld file and read.2011-05-17 03:44 AM
Thank you jaroslaw and ivanov-i,
Thank you for your time to explain all these. I learned a few lessons here. Really appreciate that. Thank you. Yong Yao :)