<?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>Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31106/nuvoton-arm-cortex-m0-how-to-put-a-const-char-string-into-rom-region</link><description> 
Hi, 

 
I can not get through with ROM -based constants. 

 
When I put a definition: 

 
const char txtParcer_OK[] = &amp;quot;ok! this is sample message ...&amp;quot;;
 

 
the compiler resides the message in RAM area. I need ROM area. 

 
I use &amp;#181;Vision V4.20.03.0</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/146938?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2012 09:59:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c409311f-196c-4537-be1d-29f11a3720b7</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Yes. &lt;b&gt;Stupid&lt;/b&gt; error, but that is it.&lt;/p&gt;

&lt;p&gt;
Thank you for the advice.&lt;/p&gt;

&lt;p&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/145424?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2012 09:41:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2f9e95bf-f68c-4101-88ba-1e14dce58781</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Not at all!&lt;/p&gt;

&lt;pre&gt;
#define  const
&lt;/pre&gt;

&lt;p&gt;
It just means that the &amp;#39;&lt;b&gt;const&lt;/b&gt;&amp;#39; keyword was effectively
stripped from the source code by the preprocessor.&lt;br /&gt;
Since &amp;#39;&lt;b&gt;const&lt;/b&gt;&amp;#39; was purely optional in all the cases tried,
there was nothing to warn about!&lt;/p&gt;

&lt;p&gt;
eg,&lt;/p&gt;

&lt;pre&gt;
const char acText[]= &amp;quot;Hallo&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
just becomes&lt;/p&gt;

&lt;pre&gt;
char acText[]= &amp;quot;Hallo&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
and&lt;/p&gt;

&lt;pre&gt;
static const acText[]= &amp;quot;...&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
just becomes&lt;/p&gt;

&lt;pre&gt;
static acText[]= &amp;quot;...&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
and&lt;/p&gt;

&lt;pre&gt;
const char txtParcer_OK[] = &amp;quot;ok! this is sample message ...&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
just becomes&lt;/p&gt;

&lt;pre&gt;
char txtParcer_OK[] = &amp;quot;ok! this is sample message ...&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
BTW: There is nothing in the &amp;#39;C&amp;#39; language definition that requires
the compiler to put &lt;b&gt;const&lt;/b&gt; items into read-only memory...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/143285?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2012 09:31:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9452ad5b-1e41-45aa-809c-60fec87df7dd</guid><dc:creator>nice day</dc:creator><description>&lt;p&gt;&lt;p&gt;
Strange that the compiler does not give a warning in such a case.
It would be generally nice, if the compiler would produce some more
warnings .... (empty code, ambiguous operator order).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/140411?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2012 08:26:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ec773af4-314c-4cfd-a9bd-cb6ad4320410</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thank you b t.&lt;/p&gt;

&lt;p&gt;
I have made the project up again from the very ground, and, by
means of one-by-one &lt;b&gt;.h&lt;/b&gt; files exclusion, found a definition in
old&amp;amp;borrowed (Microchip C32) file:&lt;/p&gt;

&lt;pre&gt;
#define  const
&lt;/pre&gt;

&lt;p&gt;
So, when I comment it, everything works as it must.&lt;/p&gt;

&lt;p&gt;
Thank you folks. Thank you all. Best regards!&lt;br /&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/140412?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2012 05:13:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fd5ad9b8-0605-46c3-927b-58836d85cd10</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks! I will try. As for the project settings - it is a copy of
Nuvoton&amp;#39;s sample projects&amp;#39; ones. I just have copied all the settings,
one by one, and whole project file.&lt;/p&gt;

&lt;p&gt;
I am also very surprised, and think, that there is some small
error somewhere in my files,&lt;br /&gt;
so it worth to try new project. Just one string.&lt;/p&gt;

&lt;p&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/131126?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 23:47:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f6e3252c-b9ca-4a35-a959-12f3d7504395</guid><dc:creator>nice day</dc:creator><description>&lt;p&gt;&lt;p&gt;
PS: Perhaps you have some very strange project settings. Best try
it first in some fresh Blinky example directly from the Keil boards
folder.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/127813?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 23:43:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1ec09a4a-2431-43ba-a988-311176956ec5</guid><dc:creator>nice day</dc:creator><description>&lt;p&gt;&lt;p&gt;
Impossible, in my code it works with &amp;quot;const char&amp;quot;. But I use CPP
compiler. But anyway should be no problem.&lt;/p&gt;

&lt;p&gt;
If I define const char acText[]= &amp;quot;Hallo&amp;quot;; , and then look at the
variable acText in the watch window, it is defined at address
0x08006678, which is clearly a code address (uVision 4.60 - ARMCC 5.0
- STM32F4).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/127826?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 23:05:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:92264564-33e9-4f1a-83ec-1652901d820c</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi b t.&lt;/p&gt;

&lt;p&gt;
Yes, I have tried all the ways. And this - too.&lt;/p&gt;

&lt;p&gt;
I have read posts for C166, for C51 - everywhere it works, but not
for Keil uVision, it seems.&lt;/p&gt;

&lt;p&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/117046?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 23:01:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fc45265a-42bf-42d9-9a7c-899310b625a2</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Dejan,&lt;/p&gt;

&lt;p&gt;
Am I sure? I look into .map file. It says, that all my consts ar
placed in 0x20000.... area. RAM data. The only way to place it to ROM
area is to give directive __attribute ((( etc.&lt;/p&gt;

&lt;p&gt;
Word &lt;b&gt;code&lt;/b&gt; , or &lt;b&gt;static&lt;/b&gt; , or &lt;b&gt;ROM&lt;/b&gt;, or any one
specific word does not work.&lt;/p&gt;

&lt;p&gt;
Plus, main problem is, that I can not add more constants now. The
program fails to work. As I comment a block of constants - it works
again properly.&lt;/p&gt;

&lt;p&gt;
So, I think, I am sure. I have tried all the ways I know to place
the constant to where it must be - so far all in vain.&lt;/p&gt;

&lt;p&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/117040?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 22:50:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e1812271-2e98-40bd-a9b6-afe947cef4b2</guid><dc:creator>nice day</dc:creator><description>&lt;p&gt;&lt;p&gt;
Did you try&lt;/p&gt;

&lt;pre&gt;
static const acText[]= &amp;quot;...&amp;quot;;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
?&lt;/p&gt;

&lt;p&gt;
This should definitely work.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/106476?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 13:25:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3bee9874-dcaa-4aa7-a5ad-f335e4b2ec28</guid><dc:creator>Dejan Durdenic</dc:creator><description>&lt;p&gt;&lt;p&gt;
Alex,&lt;/p&gt;

&lt;p&gt;
are you sure? I am too using Nuvoton&amp;#39;s M0 with a lot of cons
char&amp;#39;s (fonts) and all is placed where it should be. What does the
linker say?&lt;/p&gt;

&lt;p&gt;
- Dejan&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/80644?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2012 01:40:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:72651e34-09c0-436a-9292-a4bb113fc673</guid><dc:creator>Alex Mironov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Mike!&lt;/p&gt;

&lt;p&gt;
No Mike, I am compiling in plain C mode.&lt;/p&gt;

&lt;p&gt;
Usually, if to put &lt;b&gt;code&lt;/b&gt; or &lt;b&gt;static&lt;/b&gt; qualifier in first
place of constant definition, it works, but here - it does not.&lt;/p&gt;

&lt;p&gt;
As for local variable - I am not sure. The const is defined in the
beginning of the module. Not inside any function. Is it local? Not? I
think - it should not be local. May be, I should define it globally
by putting &lt;b&gt;extern&lt;/b&gt; definition in &lt;b&gt;.*&lt;/b&gt; file? I just have
tried - in vain.&lt;/p&gt;

&lt;p&gt;
Thank you for help,&lt;br /&gt;
Alex.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/92137?ContentTypeID=1</link><pubDate>Sun, 14 Oct 2012 02:45:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c71b6505-c168-40cb-9914-dafec8736398</guid><dc:creator>Mike Kleshov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Also, if this is a local variable, it will be allocated on the
stack even in C.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nuvoton ARM Cortex-M0. How to put a const char string into ROM region?</title><link>https://community.arm.com/thread/61253?ContentTypeID=1</link><pubDate>Sun, 14 Oct 2012 02:44:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a57b72f1-1ed6-4a08-a48e-3b6cc57cd6f4</guid><dc:creator>Mike Kleshov</dc:creator><description>&lt;p&gt;&lt;p&gt;
Are you compiling in C++ mode? I hear, in C++ the meaning of
&lt;b&gt;const&lt;/b&gt; is different from C. Could this be it?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>