<?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>Classic/Legacy CodeWarriorのトピックdeclaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160249#M2654</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to use some on/off type flags and using a byte for each flag sems a bit excessive. I'm not sure how to declare a 'bit' variable. Can anyone help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Nov 2007 17:58:07 GMT</pubDate>
    <dc:creator>stevec</dc:creator>
    <dc:date>2007-11-01T17:58:07Z</dc:date>
    <item>
      <title>declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160249#M2654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to use some on/off type flags and using a byte for each flag sems a bit excessive. I'm not sure how to declare a 'bit' variable. Can anyone help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 17:58:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160249#M2654</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2007-11-01T17:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160250#M2655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Go to the MCU-specific header files that CodeWarrior uses when you build a project with the project wizard. Look for these header files the CodeWarrior directory, inside the include directory. Specifically, there's probably a MC9S08RE16.h file (or similar) that you can examine. In this file, bits are defined for the processor's control and status registers. Use this code as a starting point to set up bit assignments within a byte for your code.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 21:37:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160250#M2655</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2007-11-01T21:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160251#M2656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The definitions in this header file seem to use variables at fixed addresses (for the registers).&amp;nbsp; I don't seem to be able to translate this over to creatiing bit flags within a declared byte e.g. flag_byte. Do I have to go to the lengths of using unions and structures? I'm relatively new to C and haven't got to using these yet.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2007 19:19:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160251#M2656</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2007-12-28T19:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160252#M2657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You need to use so called bitfields, which is a standard ANSI C construct.&lt;/DIV&gt;&lt;DIV&gt;A bitfiled is a set of bits, which can be accessed separately by the programmer.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;A bitfield is defined as follows:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;struct&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int f0: 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f1 : 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f2 : 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f3 : 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int f4: 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f5 : 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f6 : 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;f7 : 1;&lt;BR /&gt;} MyVar;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You can than access the single bit as follows:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; MyVar.f1 = 1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This will set f1 to 1.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You should be able to find more on bit fields searching on google or even in wikipedia.&lt;/DIV&gt;&lt;DIV&gt;I hope it helps.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jan 2008 18:14:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160252#M2657</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-01-04T18:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160253#M2658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Sorry to bring this thread back. But i am facing the same problem with declaring a bit so i can use it for flag. for example.&lt;BR /&gt;&lt;BR /&gt;typedef bit &amp;nbsp; BIT;&lt;BR /&gt;&lt;BR /&gt;I get this error message&lt;BR /&gt;&lt;BR /&gt;Error: C2450: Expected: ; =,&lt;BR /&gt;define.h line 10&lt;BR /&gt;Error: Compile failed&lt;BR /&gt;&lt;BR /&gt;BIT debug_flag; //If i change BIT to BYTE the error for this line goes away&lt;BR /&gt;&lt;BR /&gt;It this means that CW or the microprocessor doesn't support individual declaration of single bit?&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Designer11 on &lt;SPAN class="date_text"&gt;2008-08-29&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:51 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Aug 2008 04:34:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160253#M2658</guid>
      <dc:creator>Designer11</dc:creator>
      <dc:date>2008-08-30T04:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: declaring a bit variable..CW 5.7.0.2015...MC9S08RE16</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160254#M2659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The problem with your typedef is that &lt;FONT face="Courier New"&gt;bit&lt;/FONT&gt; is not a valid data type.&amp;nbsp; For a bit field structure, a specific bit is an element of that structure, and needs to be referenced as such.&amp;nbsp; As previously described by CrasyCat, the following would seem to represent what you are attempting to achieve.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;struct {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; word debug&amp;nbsp; :1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;}&amp;nbsp;flags;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#define debug_flag&amp;nbsp; flag.debug&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;debug_flag = 1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;An alternative to using bit fields is to use bit masks.&amp;nbsp; This might be simplified with the use of the following macros.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;// Bit control macros:&lt;BR /&gt;#define&amp;nbsp; bset(n,reg)&amp;nbsp; (reg) |= (1 &amp;lt;&amp;lt; (n))&lt;BR /&gt;#define&amp;nbsp; bclr(n,reg)&amp;nbsp; (reg) &amp;amp;= ~(1 &amp;lt;&amp;lt; (n))&lt;BR /&gt;#define&amp;nbsp; btest(n,reg) ((reg) &amp;amp; (1 &amp;lt;&amp;lt; (n)))&amp;nbsp; // Value 0 or 2^n&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#define debug&amp;nbsp; 0&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;byte flags;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;bset(debug, flags);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;if (btest(debug, flags) ... ;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Aug 2008 17:09:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/declaring-a-bit-variable-CW-5-7-0-2015-MC9S08RE16/m-p/160254#M2659</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-08-30T17:09:00Z</dc:date>
    </item>
  </channel>
</rss>

