<?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>CodeWarrior for MCUのトピックRe: HCS12 - How to make a read only absolute variable non initialized ?</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201594#M7591</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about not using not portable C extension @, and define pitcnt0 like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define pitcnt0 (*(volatile const unsigned short *)0x34A)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need debugger visible variable for pitcnt0, then I think you need to define your own N/I segment for pitcnt0 in PRM file and allocate pitcnt0 in that segment. A lot of work for not very important&amp;nbsp;result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Jan 2012 16:44:21 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2012-01-30T16:44:21Z</dc:date>
    <item>
      <title>HCS12 - How to make a read only absolute variable non initialized ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201593#M7590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a read only register defined&lt;/P&gt;&lt;PRE&gt;volatile const unsigned short pitcnt0 @0x034a;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;When I define the register as above, the linker creates an entry in hex file for that address, which is causing issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the map file:&lt;/P&gt;&lt;PRE&gt;.abs_section_34a&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34B&amp;nbsp;&amp;nbsp; .absSeg148&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This generates data in the hex&amp;nbsp; and abs, which I don't want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A register not defined at const works ok:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;volatile unsigned short pitld1 @0x034c;&lt;/PRE&gt;&lt;P&gt;The map file shows it as non initialized:&lt;/P&gt;&lt;PRE&gt;.abs_section_34c&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; 2&amp;nbsp;&amp;nbsp; N/I&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x34D&amp;nbsp;&amp;nbsp; .absSeg149&lt;/PRE&gt;&lt;P&gt;I would like to define read only registers as const, to have the compile complain if I try to write to them. Any Ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 14:48:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201593#M7590</guid>
      <dc:creator>djsimpson</dc:creator>
      <dc:date>2012-01-30T14:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - How to make a read only absolute variable non initialized ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201594#M7591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about not using not portable C extension @, and define pitcnt0 like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define pitcnt0 (*(volatile const unsigned short *)0x34A)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need debugger visible variable for pitcnt0, then I think you need to define your own N/I segment for pitcnt0 in PRM file and allocate pitcnt0 in that segment. A lot of work for not very important&amp;nbsp;result.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 16:44:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201594#M7591</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-01-30T16:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - How to make a read only absolute variable non initialized ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201595#M7592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Kef.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try your suggestion, but it is nice to be able to view the variables in the debugger when needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My aim was to try to stop myself (and other engineers in my company) from making silly mistakes. This comes from experience where I spent considerable time staring at code not working because I confused variables in the PIT, and was writing to a read only register.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured if I defined the read only variables as const, then the compiler will flag my error before I even get to run my code.&amp;nbsp; I did think about defining individual sections, but agree that did seem like too much effort.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 06:32:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201595#M7592</guid>
      <dc:creator>djsimpson</dc:creator>
      <dc:date>2012-01-31T06:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - How to make a read only absolute variable non initialized ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201596#M7593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may use union or struct with const fields. Map file shows N/I for such struct and it should be visible in debugger.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;union {const unsigned short data;} pitcnt0_ @ 0x34A;&lt;/P&gt;&lt;P&gt;#define pitcnt0 pitcnt0_.data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 18:51:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201596#M7593</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-01-31T18:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - How to make a read only absolute variable non initialized ?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201597#M7594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The union seems works OK. I will give it try and see.&lt;/P&gt;&lt;P&gt;Only minor issue is remembering the variable has a trailing underscore in the debugger.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 19:59:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS12-How-to-make-a-read-only-absolute-variable-non-initialized/m-p/201597#M7594</guid>
      <dc:creator>djsimpson</dc:creator>
      <dc:date>2012-01-31T19:59:11Z</dc:date>
    </item>
  </channel>
</rss>

