<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Save array data in code segment</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/afb32de10a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/afb32de10a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/afb32de10a/</id><updated>2020-02-27T21:40:27.771000Z</updated><subtitle>Recent posts to Save array data in code segment</subtitle><entry><title>Save array data in code segment</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/afb32de10a/?limit=25#c1b9" rel="alternate"/><published>2020-02-27T21:40:27.771000Z</published><updated>2020-02-27T21:40:27.771000Z</updated><author><name>Igor Petrov</name><uri>https://forge.codesys.com/u/igor-petrov/</uri></author><id>https://forge.codesys.com0690cda5564099d5831ed26b15cee008935d1e9b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The generated code belongs to initialization section executed only once. Therefore intensive optimization in it is not important for the program speed.&lt;/p&gt;
&lt;p&gt;If you have few memory and really need to optimize code by size then you may try the next trick. I used it for 8051 system with tiny memory. &lt;/p&gt;
&lt;p&gt;1) You can declare string instead of BYTE array. For example: &lt;/p&gt;
&lt;p&gt;It have to generate compact string in code memory with compact mem copy function for initialization.&lt;/p&gt;
&lt;p&gt;2) There are 2 methods to use a string like an rray. A) Declare both the string and the array on the same address in 'M' memory; B) Make pointer to the array and set it to ADR of the string. &lt;/p&gt;
&lt;p&gt;Regards  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Save array data in code segment</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/afb32de10a/?limit=25#2e46" rel="alternate"/><published>2020-02-27T21:40:26.125000Z</published><updated>2020-02-27T21:40:26.125000Z</updated><author><name>jan233321</name><uri>https://forge.codesys.com/u/jan233321/</uri></author><id>https://forge.codesys.com391439537a79890ffc303a8dc22ed3cc417beb21</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I'm trying to create constant arrays of bytes. If I use global variables and VAR_CONSTANT, it looks like:&lt;/p&gt;
&lt;p&gt;code in ST:&lt;/p&gt;
&lt;p&gt;generated code:&lt;/p&gt;
&lt;p&gt;255 times. If you have more than 1 array then more times... .&lt;/p&gt;
&lt;p&gt;This code is not very optimised, it is consuming a large amount of code memory (1 array item needs 12 bytes of code memory).&lt;/p&gt;
&lt;p&gt;Does exist any possibility to create this array directly in program memory segment (in flash - any pragma)?  Next step is to create one small loop to copy data from flash to ram.&lt;/p&gt;
&lt;p&gt;Thans&lt;/p&gt;
&lt;p&gt;Jan&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>