<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>assign value to flash memory</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/37661/assign-value-to-flash-memory</link><description> 
Hi Guys 

 
How am i able to assign values to a variable i have stored in
flash so that it is included in the hex file? 

 
For example: i have declared a variable 
volatile unsigned char code err_msgs[10][20] _at_ FLASHSTART; 

 
but cannot assign</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/151206?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 02:09:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e6dba77-c5bb-476b-8ffc-8a0dfedf1ad9</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
ah i see, okay thanx for the help again&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150671?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:57:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cf638e9d-bcd0-4c1b-b24c-1a00e1dbd924</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Getting there, but a bit more study still required.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150670?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:44:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f7cc54a7-bab8-4ea4-8f36-0ad87823440f</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Don&amp;#39;t you believe in the compiler being capable enough to
zero-terminate your strings for you?&lt;/p&gt;

&lt;p&gt;
The only time the compiler will not zero-terminate a string, is if
you assign to a fixed-size array, and the string has as many
characters as the array - but then, no &amp;quot;\0&amp;quot; will help you since there
are no room for that character...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150273?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:39:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a2f84e30-158d-4fbf-ae2d-7e5d5638c000</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
i think i found what i needed to do, just needed to put&lt;br /&gt;
= {&amp;quot;MSG1\0&amp;quot;,&amp;quot;MSG2\0&amp;quot;,&amp;quot;MSG3\0&amp;quot;};&lt;/p&gt;

&lt;p&gt;
thanx for you help&lt;/p&gt;

&lt;p&gt;
Xarion&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/149837?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:19:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0ef81f87-5b76-4550-9b19-699340346140</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;was just following &lt;a href="http://www.nxp.com/acrobat_download/applicationnotes/AN10342_1.pdf"&gt;www.nxp.com/.../AN10342_1.pdf&lt;/a&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Why are you following that App Note?&lt;/p&gt;

&lt;p&gt;
That is about storing &lt;i&gt;&lt;b&gt;and updating&lt;/b&gt;&lt;/i&gt; data in flash
using IAP functions - you don&amp;#39;t need any of that just to have a set
of fixed message strings in flash!&lt;/p&gt;

&lt;p&gt;
Perhaps if you described what you&amp;#39;re actually trying to
achieve...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150272?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:17:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e586fbd5-0480-46c4-bc4e-bba75e8138f9</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
yes sorry, had some brain failure there i cant just strcpy ok i&amp;#39;ll
take a look at some books&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150662?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:11:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:759d512f-1109-4d38-a96d-2cdfd9abe4f6</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;yeah i can just strcpy into the array at runtime&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;No, you can &lt;i&gt;not!&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
You not only need a &amp;#39;C&amp;#39; textbook, but also an 8051 textbook!&lt;/p&gt;

&lt;p&gt;
As far as &amp;#39;C&amp;#39; is concerned, you cannot write to a &lt;b&gt;const&lt;/b&gt;
object;&lt;/p&gt;

&lt;p&gt;
As far as the 8051 is concerned, you cannot write to CODE
space.&lt;/p&gt;

&lt;p&gt;
You need to &lt;i&gt;&lt;b&gt;initialise&lt;/b&gt;&lt;/i&gt; the array in its definition -
in the same way that you can initialise any other &amp;#39;C&amp;#39; array in its
definition...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/149834?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:07:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1fe1e8b3-63fc-43f7-acab-00e5ef8cb3c6</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;The &amp;#39;volatile&amp;#39; will indicate that the compiler will not
optimize out the array if it isn&amp;#39;t initialized...&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;a href="http://www.nxp.com/acrobat_download/applicationnotes/AN10342_1.pdf"&gt;www.nxp.com/.../AN10342_1.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
No, I think that&amp;#39;s wrong!&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;volatile&lt;/b&gt; does not affect the allocation of variables; it
just prevents optimisation of the &lt;i&gt;&lt;b&gt;access&lt;/b&gt;&lt;/i&gt; to
variables!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/150276?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 01:05:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1088d5f8-48ee-449f-99eb-b7ec6eb68cc0</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
yeah i can just strcpy into the array at runtime but thats going
to use more code to write each character to flash as to write to
flash its not just assigning to a variable, i&amp;#39;m running tight with
space which is my real aim in doing this.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/149836?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 00:59:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7a4ef12b-a4b7-4344-95ab-0678b091b451</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;how can i assign my 10 strings to this array?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The &lt;b&gt;code&lt;/b&gt; keyword has no effect on this - you do it the same
way you would for any standard ANSI &amp;#39;C&amp;#39; array with any standard ANSI
&amp;#39;C&amp;#39; compiler.&lt;br /&gt;
Therefore, see any &amp;#39;C&amp;#39; textbook.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;not exactly sure what volatile means&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;volatile&lt;/b&gt; is a standard ANSI &amp;#39;C&amp;#39; keyword - it has no special
meaning in Keil C51.&lt;br /&gt;
Therefore, again, see any &amp;#39;C&amp;#39; textbook.&lt;/p&gt;

&lt;p&gt;
See also: &lt;a href="http://www.keil.com/forum/docs/thread11735.asp"&gt;http://www.keil.com/forum/docs/thread11735.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/149363?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 00:38:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e8f8525d-de69-4440-81d1-45c22eccfa6e</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
not sure why volatile, was just following &lt;a href="http://www.nxp.com/acrobat_download/applicationnotes/AN10342_1.pdf"&gt;www.nxp.com/.../AN10342_1.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
not exactly sure what volatile means&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/148888?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 00:35:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:80d70616-15b2-4aab-989e-da3f58e6a1e1</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;pre&gt;
volatile unsigned char code err_msgs[10][20];
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Why on earth would you define that as &lt;b&gt;volatile&lt;/b&gt; ??!!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/124428?ContentTypeID=1</link><pubDate>Wed, 06 Feb 2008 00:32:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bd6a3479-31ac-4d29-a054-a3ebd76eeb25</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ah yes that makes more sense and it works :) thanx!&lt;/p&gt;

&lt;p&gt;
now have my array ...&lt;/p&gt;

&lt;p&gt;
volatile unsigned char code err_msgs[10][20];&lt;/p&gt;

&lt;p&gt;
how can i assign my 10 strings to this array? pragma?&lt;/p&gt;

&lt;p&gt;
Xarion&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/113633?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2008 23:44:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8888d8ce-d1a6-4df2-8da7-93d81081a637</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sort of!&lt;/p&gt;

&lt;p&gt;
The &lt;b&gt;code&lt;/b&gt; keyword specifies that it is to be located in CODE
space; if your flash is in your CODE space, then it will end up in
your flash!&lt;/p&gt;

&lt;p&gt;
There is no need for &lt;b&gt;_at_&lt;/b&gt; simply to locate the strings into
CODE space.&lt;/p&gt;

&lt;p&gt;
You only use &lt;b&gt;_at_&lt;/b&gt; when you need to define a specific
&lt;i&gt;&lt;b&gt;address&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/100234?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2008 22:56:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:57faae84-63f7-43a7-9739-93a4b82585d6</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
ah i just noticed now is that the &amp;quot;code&amp;quot; keyword defines that it
is in flash mem. right?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/75972?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2008 22:54:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:29c946b5-6695-4580-896c-f8b59f636cf0</guid><dc:creator>Xarion Comoretto</dc:creator><description>&lt;p&gt;&lt;p&gt;
The _AT_ was to define where the flash memory resides, its not a
ram variable, is there another way to declare variables in flash
memory?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: assign value to flash memory</title><link>https://community.arm.com/thread/49378?ContentTypeID=1</link><pubDate>Tue, 05 Feb 2008 22:51:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fbad0cf1-e99b-4115-a4b3-84eb45815ac9</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Why are you using &lt;b&gt;_at_&lt;/b&gt;?&lt;/p&gt;

&lt;p&gt;
If you don&amp;#39;t use &lt;b&gt;_at_&lt;/b&gt;, then you can assign initial
values!&lt;/p&gt;

&lt;p&gt;
If you must use &lt;b&gt;_at_&lt;/b&gt;, then read the Knowledgebase article
linked at the end of the &lt;b&gt;Manual&lt;/b&gt; page:&lt;br /&gt;
&lt;a href="http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm"&gt;http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>