<?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 Pack struct on 56F8367 in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pack-struct-on-56F8367/m-p/133603#M666</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;I tried to use a union of struct and char array to handle data in RAM and save it to an I2C EEPROM.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;On other controllers this was no problem because the compilers put one variable of the struct after the other.&amp;nbsp; The CodeWarrior leaves some addresses blank. Is it&amp;nbsp;possible to configure it the way he didn't leave spaces?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Mike&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by TheSealion on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-05-11&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:57 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2007 18:51:14 GMT</pubDate>
    <dc:creator>TheSealion</dc:creator>
    <dc:date>2007-05-11T18:51:14Z</dc:date>
    <item>
      <title>Pack struct on 56F8367</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pack-struct-on-56F8367/m-p/133603#M666</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;I tried to use a union of struct and char array to handle data in RAM and save it to an I2C EEPROM.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;On other controllers this was no problem because the compilers put one variable of the struct after the other.&amp;nbsp; The CodeWarrior leaves some addresses blank. Is it&amp;nbsp;possible to configure it the way he didn't leave spaces?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Mike&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by TheSealion on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-05-11&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:57 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2007 18:51:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pack-struct-on-56F8367/m-p/133603#M666</guid>
      <dc:creator>TheSealion</dc:creator>
      <dc:date>2007-05-11T18:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pack struct on 56F8367</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pack-struct-on-56F8367/m-p/133604#M667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;First of all, I would like to apologize for the time that it has taken us to get back to you on this issue.&lt;BR /&gt;We appreciate your patience and want to let you know that we are doing efforts to improve our response time.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;See below some info regarding the structure Alignment.&lt;/DIV&gt;&lt;DIV&gt;Hope this will help you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Problem: Explanation/Clarification on structure alignment.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Description:&lt;BR /&gt;Question regarding the structure alignment.&lt;BR /&gt;Se below an example showing the problem.&lt;BR /&gt;See car2,car3,car4,car5,car6 and car7.&lt;BR /&gt;The tool reserve an int instead of a char.&lt;BR /&gt;Is it not possible to align better the structure ?&lt;/DIV&gt;&lt;DIV&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;struct&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit0&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit1&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit2&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit3&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit5&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit6&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int bit7&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit8&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit9&amp;nbsp;&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit10&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit11&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit12&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit13&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit14&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;unsigned int Bit15&amp;nbsp;&amp;nbsp; :1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;} B;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;int W16;&lt;BR /&gt;&amp;nbsp;} car01;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car2;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car3;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car4;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car5;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car6;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;unsigned char var3;&lt;BR /&gt;&amp;nbsp;} car7;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}my_struct;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;typedef union&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; my_struct data;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; unsigned char car[8];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; long int W32[2];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}my_2ndStruct;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Resolution:&lt;/DIV&gt;&lt;DIV&gt;The specifications for 56800e are such that we cannot modify this behavior in build tools.&lt;BR /&gt;If you look into Targeting_56800E.pdf at data alignment requirements, one can see "&lt;BR /&gt;• Structures — word boundaries (not byte boundaries).&lt;BR /&gt;NOTE A structure containing only bytes still is word aligned.&lt;BR /&gt;This holds also for unions.&lt;BR /&gt;This is why you can see one byte padding, besides the char data.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;The structure mytest has 2 int and 2 char and take 3 int only.&lt;BR /&gt;According to the manual is should take 4 int.&lt;BR /&gt;struct&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;int test1;&lt;BR /&gt;&amp;nbsp;int test2;&lt;BR /&gt;&amp;nbsp;char test3;&lt;BR /&gt;&amp;nbsp;char test4;&amp;nbsp;&lt;BR /&gt;}mytest;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;Please note that the specifications are for data alignment and not data size.&lt;BR /&gt;So, char can be aligned on byte boundary.&lt;BR /&gt;That is why in second example you see test4 aligned on byte boundary.&lt;/DIV&gt;&lt;DIV&gt;Still, if test4 is included in another structure or union, it has to&lt;BR /&gt;stay on word boundary because of the restrictions for structures.&lt;BR /&gt;That is why one byte padding will be introduced between test3 and test4.&lt;BR /&gt;So, yes the entire structure mytest will take 4 ints here:&lt;/DIV&gt;&lt;DIV&gt;struct&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;int test1;&lt;BR /&gt;&amp;nbsp;int test2;&lt;BR /&gt;&amp;nbsp;char test3;&lt;BR /&gt;&amp;nbsp;union&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;char test4;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;};&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}mytest;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards&lt;/DIV&gt;&lt;DIV&gt;Pascal Irrle&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2007 18:54:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pack-struct-on-56F8367/m-p/133604#M667</guid>
      <dc:creator>trytohelp</dc:creator>
      <dc:date>2007-06-21T18:54:49Z</dc:date>
    </item>
  </channel>
</rss>

