<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Coldfire register access, best practice and compiler dependency in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173266#M6578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm assuming the second example should read as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ADC_CTRL1 = (ADC_CTRL1 | 0x2000); // start an ADC conversion (address is 0x40190000 and is defined as a short word)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(ADC_CTRL1 rather than ADC_CTRL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To me it's clear: it's a case of missing &lt;EM&gt;volatile&lt;/EM&gt; keyword.&lt;/P&gt;&lt;P&gt;Why would anyone want to disable optimization or stick with a certain compiler version just to avoid declaring the register as volatile? It's beyond me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;- mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Feb 2010 14:44:48 GMT</pubDate>
    <dc:creator>scifi</dc:creator>
    <dc:date>2010-02-05T14:44:48Z</dc:date>
    <item>
      <title>Coldfire register access, best practice and compiler dependency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173265#M6577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;BR /&gt;&lt;BR /&gt;Consider the following code:&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ADC_CTRL1 |= 0x2000; // start an ADC conversion (address is 0x40190000 and is defined as a short word)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Now consider this code&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ADC_CTRL1 = (ADC_CTRL | 0x2000); // start an ADC conversion (address is 0x40190000 and is defined as a short word)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Is there a difference?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assembler gives, in the two cases,&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;0x0000000E&amp;nbsp; 0x207C40190000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movea.l&amp;nbsp; #1075380224,a0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '@...'&lt;BR /&gt;0x00000014&amp;nbsp; 0x08D00005&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bset&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #5,(a0)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;0x00000018&amp;nbsp; 0x7000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; moveq&amp;nbsp;&amp;nbsp;&amp;nbsp; #0,d0&lt;BR /&gt;0x0000001A&amp;nbsp; 0x303940190000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.w&amp;nbsp;&amp;nbsp; 0x40190000,d0&lt;BR /&gt;0x00000020&amp;nbsp; 0x08C0000D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bset&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #13,d0&lt;BR /&gt;0x00000024&amp;nbsp; 0x33C040190000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.w&amp;nbsp;&amp;nbsp; d0,0x40190000&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;The first fails and the second works....(the reason being that the access to the register in the first case is performed as a bit set acting on the first byte in the register whereas the second manipulates the value in a data register and performs a short word destination write - presumably this register doesn't like to be addresses as a byte.)&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;This leads to a question as to best practice in these situations? The problem can be solved by:&lt;BR /&gt;a) disabling optimisation&lt;BR /&gt;b) ensuring that the register is declared as volatile (although the volatile declaration is not explicitly causing the register to be handled as a volatile but does avoid the use of bset directed to a single byte).&lt;BR /&gt;c) use CW 6.4 rather than CW 7.2 (CW6.4 tends to use ori rather than bset when setting bits)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe a bit of a theoretical topic but still interesting in some way....&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 04:54:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173265#M6577</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2010-02-05T04:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Coldfire register access, best practice and compiler dependency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173266#M6578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm assuming the second example should read as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ADC_CTRL1 = (ADC_CTRL1 | 0x2000); // start an ADC conversion (address is 0x40190000 and is defined as a short word)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(ADC_CTRL1 rather than ADC_CTRL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To me it's clear: it's a case of missing &lt;EM&gt;volatile&lt;/EM&gt; keyword.&lt;/P&gt;&lt;P&gt;Why would anyone want to disable optimization or stick with a certain compiler version just to avoid declaring the register as volatile? It's beyond me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;- mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 14:44:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173266#M6578</guid>
      <dc:creator>scifi</dc:creator>
      <dc:date>2010-02-05T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Coldfire register access, best practice and compiler dependency</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173267#M6579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, typo on the regster name in second case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is hyperthetical so, of course, the compiler change is also only hyperthetical, but I must admit that I thought compilers would compile the two cases x |= y; and x = (x | y); the sameway but one learns something new every day...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Feb 2010 20:18:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Coldfire-register-access-best-practice-and-compiler-dependency/m-p/173267#M6579</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2010-02-05T20:18:29Z</dc:date>
    </item>
  </channel>
</rss>

