<?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: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180675#M6124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CrazyCat,&lt;/P&gt;&lt;P&gt;thank you for your quick replay.&lt;/P&gt;&lt;P&gt;You are right, I did not include the header file, in which the prototype is defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I included the header file, but no change in the behaviour.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I renamed the function from i2c_read() to i2c_reaD() (in protoype, implementation of function and function call), just to avoid, that there is elsewhere another function which that name: But no change, too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I let create the predef.h file, to get to know what is defined (but I do not see a define, which may cause this problem):&lt;/P&gt;&lt;PRE&gt;#define __STDC__ 0#define __VERSION__ 5032#define __VERSION_STR__ "V-5.0.32"#define __MWERKS__ 1#define __BITFIELD_LSBIT_FIRST__#define __BITFIELD_MSBYTE_FIRST__#define __BITFIELD_MSWORD_FIRST__#define __BITFIELD_TYPE_SIZE_REDUCTION__#define __SMALL__#define __HC08__#define __PTR_SIZE_2__#define __HC08_ICG__#define __HCS08__#define __FLOAT_IS_IEEE32__#define __DOUBLE_IS_IEEE64__#define __LONG_DOUBLE_IS_IEEE64__#define __LONG_LONG_DOUBLE_IS_IEEE64__#define __CHAR_IS_UNSIGNED__#define __CHAR_IS_8BIT__#define __SHORT_IS_16BIT__#define __INT_IS_16BIT__#define __ENUM_IS_16BIT__#define __LONG_IS_32BIT__#define __LONG_LONG_IS_32BIT__#define __SIZE_T_IS_UINT__#define __PTRDIFF_T_IS_INT__#define __ENUM_IS_SIGNED__#define __VTAB_DELTA_IS_16BIT__#define __WCHAR_T_IS_UCHAR__#define __PTRMBR_OFFSET_IS_16BIT__#define __PLAIN_BITFIELD_IS_SIGNED__#define __ELF_OBJECT_FILE_FORMAT__#define __PRODUCT_HICROSS_PLUS__#define __HIWARE__#define __ARCHIMEDES__#define __OPTIMIZE_FOR_SIZE__#define __BIG_ENDIAN__&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I also tried with and without optimization. No changes, always the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:30:40 GMT</pubDate>
    <dc:creator>ttom</dc:creator>
    <dc:date>2020-10-29T09:30:40Z</dc:date>
    <item>
      <title>function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180673#M6122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a HCS08SG32 and want to do the following (environment: Codewarrior 6.3, hardware: demo board DEMO9S08SH32/SG32) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call of function:&lt;/P&gt;&lt;P&gt;i2c_read (0x20, 0x30, 2, send);&lt;/P&gt;&lt;P&gt;I discoverd an error, because inside the function i2c_read() the values of the parameters are not equal to the call of the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where send is defined:&lt;/P&gt;&lt;PRE&gt;unsigned char send[11];&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i2c_read is defined as:&lt;/P&gt;&lt;PRE&gt;unsigned char i2c_read (unsigned char devaddr, unsigned char addr, unsigned char len, unsigned char *data);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I step by the debugger into the function, the parameters are pushed at the stack as 16 bits values (see attached file), but are popped as 8 bit values. As a result: the parameters inside the function are cut and have not the values like in the call (devaddr = 2, addr=0, len =0) .&lt;/P&gt;&lt;P&gt;If I change the datatype of the parameters to a 16 Bit value, it works.&lt;/P&gt;&lt;P&gt;But I want to understand, why 8 Bit parameters are pushed to stack as 16 Bit Values and wrongly popped inside the function as 8 bit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already went trough the compiler options, but did not find a setting to influence this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope, somebody can remove the tomatos from my eyes?&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:30:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180673#M6122</guid>
      <dc:creator>ttom</dc:creator>
      <dc:date>2020-10-29T09:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180674#M6123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you forget to place a prototype of function i2c_read prior to invoking it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please preprocess the source file where the function is called and look for a prototype for function i2c_read.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2012 18:55:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180674#M6123</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2012-07-18T18:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180675#M6124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CrazyCat,&lt;/P&gt;&lt;P&gt;thank you for your quick replay.&lt;/P&gt;&lt;P&gt;You are right, I did not include the header file, in which the prototype is defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I included the header file, but no change in the behaviour.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I renamed the function from i2c_read() to i2c_reaD() (in protoype, implementation of function and function call), just to avoid, that there is elsewhere another function which that name: But no change, too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I let create the predef.h file, to get to know what is defined (but I do not see a define, which may cause this problem):&lt;/P&gt;&lt;PRE&gt;#define __STDC__ 0#define __VERSION__ 5032#define __VERSION_STR__ "V-5.0.32"#define __MWERKS__ 1#define __BITFIELD_LSBIT_FIRST__#define __BITFIELD_MSBYTE_FIRST__#define __BITFIELD_MSWORD_FIRST__#define __BITFIELD_TYPE_SIZE_REDUCTION__#define __SMALL__#define __HC08__#define __PTR_SIZE_2__#define __HC08_ICG__#define __HCS08__#define __FLOAT_IS_IEEE32__#define __DOUBLE_IS_IEEE64__#define __LONG_DOUBLE_IS_IEEE64__#define __LONG_LONG_DOUBLE_IS_IEEE64__#define __CHAR_IS_UNSIGNED__#define __CHAR_IS_8BIT__#define __SHORT_IS_16BIT__#define __INT_IS_16BIT__#define __ENUM_IS_16BIT__#define __LONG_IS_32BIT__#define __LONG_LONG_IS_32BIT__#define __SIZE_T_IS_UINT__#define __PTRDIFF_T_IS_INT__#define __ENUM_IS_SIGNED__#define __VTAB_DELTA_IS_16BIT__#define __WCHAR_T_IS_UCHAR__#define __PTRMBR_OFFSET_IS_16BIT__#define __PLAIN_BITFIELD_IS_SIGNED__#define __ELF_OBJECT_FILE_FORMAT__#define __PRODUCT_HICROSS_PLUS__#define __HIWARE__#define __ARCHIMEDES__#define __OPTIMIZE_FOR_SIZE__#define __BIG_ENDIAN__&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I also tried with and without optimization. No changes, always the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:30:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180675#M6124</guid>
      <dc:creator>ttom</dc:creator>
      <dc:date>2020-10-29T09:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180676#M6125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CrazyCat,&lt;/P&gt;&lt;P&gt;I have now created a preprocessor output (main.pre) file, and had a look into it.&lt;/P&gt;&lt;P&gt;Inside this file, there is no prototype of the function i2c_reaD(), but there is the include of i2c.h. Within this file, the function i2c_reaD() is defined by the prototype.&lt;/P&gt;&lt;P&gt;I am not sure if you meant this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 02:34:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180676#M6125</guid>
      <dc:creator>ttom</dc:creator>
      <dc:date>2012-07-19T02:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180677#M6126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; The wrong parameter passing is due to the missing prototype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Now you need to understand why the prototype is not added to the preprocessor listing.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Check if there is any conditional compilation&amp;nbsp; directive (#if or #ifdef) that might comment out the function prototype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 16:32:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180677#M6126</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2012-07-19T16:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180678#M6127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;I suggest to use the -Wpd compiler option: this option will flag any missing prototype as an error.&lt;/P&gt;&lt;P&gt;That way you can easily spot the programming error (hopefully).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;BK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 17:19:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180678#M6127</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2012-07-19T17:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: function with 8bit Parameters pushes 16 bit to stack but pops only 8 bit</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180679#M6128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;many thanks for your help!&lt;/P&gt;&lt;P&gt;It is solved now:&lt;/P&gt;&lt;P&gt;In my task, I want to switch the interface to a eeprom from SPI to I2C.&lt;/P&gt;&lt;P&gt;Just started by copy&amp;amp;paste the spi.c and spi.h files and rename to i2c.c and .h.&lt;/P&gt;&lt;P&gt;In the header file, there was the #define around the complete file&lt;/P&gt;&lt;P&gt;#ifndef _SPI_H_&lt;/P&gt;&lt;P&gt;#define _SPI_H_&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, of course, i did not rename this define into I2C...&lt;/P&gt;&lt;P&gt;So I included the right file in my main.c, but the prototype was not inserted because the spi.h and spi.c file is still in the project...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks again for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 20:03:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/function-with-8bit-Parameters-pushes-16-bit-to-stack-but-pops/m-p/180679#M6128</guid>
      <dc:creator>ttom</dc:creator>
      <dc:date>2012-07-19T20:03:18Z</dc:date>
    </item>
  </channel>
</rss>

