<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/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/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Is there a way to tell the compiler not to optimise a particular piece of code?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16342/is-there-a-way-to-tell-the-compiler-not-to-optimise-a-particular-piece-of-code</link><description>Hi,
I am using nrf51822xxaa , Keil Uvision 5.14.2.1. SDK 10.0.0 and S130. I need optimisation level O3 for most parts of the code, except for one part (about 10 lines of code) which I need to be O0. Is it possible? If so, how to achieve this? Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Sep 2016 08:31:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16342/is-there-a-way-to-tell-the-compiler-not-to-optimise-a-particular-piece-of-code" /><item><title>RE: Is there a way to tell the compiler not to optimise a particular piece of code?</title><link>https://devzone.nordicsemi.com/thread/62477?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 08:31:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95602d53-b8eb-48d7-8156-a868120500e4</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;See also  &lt;strong&gt;#pragma Onum&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.keil.com/support/man/docs/armcc/armcc_chr1359124988971.htm"&gt;www.keil.com/.../armcc_chr1359124988971.htm&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there a way to tell the compiler not to optimise a particular piece of code?</title><link>https://devzone.nordicsemi.com/thread/62476?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 08:29:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5de0f12f-3788-427c-95d2-5ce975cf97e3</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;uVision also allows you to set &lt;strong&gt;per-file&lt;/strong&gt; options.&lt;/p&gt;
&lt;p&gt;This has nothing to do with Nordic; it is standard Keil operation - covered in the standard Keil documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.keil.com/support/man/docs/uv4/uv4_ca_filegrp_att.htm"&gt;www.keil.com/.../uv4_ca_filegrp_att.htm&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there a way to tell the compiler not to optimise a particular piece of code?</title><link>https://devzone.nordicsemi.com/thread/62478?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 02:20:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e15f9aba-2656-462a-89e7-38044d00d16a</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Thanks. This method works!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there a way to tell the compiler not to optimise a particular piece of code?</title><link>https://devzone.nordicsemi.com/thread/62475?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 02:12:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4772f1b-848f-4a75-b556-7261e52c8010</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;I have not tried it personally, but I see a overriding compiling option for each &lt;strong&gt;group&lt;/strong&gt; in Keil.&lt;/p&gt;
&lt;p&gt;You could put all such code in some files, then put all such files into a specific group and then adjust the compiling option of that group according to your wish.&lt;/p&gt;
&lt;p&gt;Just want to update to include @awneil&amp;#39;s helpful comments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;uVision also allows you to set per-file options.&lt;/p&gt;
&lt;p&gt;This has nothing to do with Nordic; it is standard Keil operation - covered in the standard Keil documentation:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.keil.com/support/man/docs/uv4/uv4_ca_filegrp_att.htm"&gt;www.keil.com/.../uv4_ca_filegrp_att.htm&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;See also #pragma Onum&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.keil.com/support/man/docs/armcc/armcc_chr1359124988971.htm"&gt;www.keil.com/.../armcc_chr1359124988971.htm&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>