<?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 Development ToolsのトピックRe: Why uint16_t assignment does not work</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1359149#M8644</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189409"&gt;@xuedongyang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply!&lt;/P&gt;
&lt;P&gt;Interesting! What if you go back to here ,&amp;nbsp;&amp;nbsp;define temp value arrays as fixed16_t&amp;nbsp; and test again?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_1-1634788378764.png" style="width: 616px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/159720i3CBC59261018B979/image-dimensions/616x271?v=v2" width="616" height="271" role="button" title="diego_charles_1-1634788378764.png" alt="diego_charles_1-1634788378764.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Maybe the problem is an actual&amp;nbsp; difference in the data type, as you mention with the fixed16_t .&amp;nbsp; and the compiler can not see this. But during in assembly, the data is written to &lt;STRONG&gt;img&lt;/STRONG&gt; and &lt;STRONG&gt;real&amp;nbsp;&lt;/STRONG&gt; in special way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Diego.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Oct 2021 04:02:29 GMT</pubDate>
    <dc:creator>diego_charles</dc:creator>
    <dc:date>2021-10-21T04:02:29Z</dc:date>
    <item>
      <title>Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1353871#M8628</link>
      <description>&lt;P&gt;Hi, experts,&lt;/P&gt;&lt;P&gt;I am trying to assign a 16-bit hex value to a uint16_t variable (actually an element of uint16_t array), but it does not work. I see the value is alway 0x7FFF for real and 0 for imaginary parts in CodeWarrior..&lt;/P&gt;&lt;P&gt;Any idea why? Did I miss anything? If I do the assignment for a floating point data, it works well. The value I see from CodeWarrior is just as I expected. But this uint16_t does not work the same way.....&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 04:37:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1353871#M8628</guid>
      <dc:creator>xuedongyang</dc:creator>
      <dc:date>2021-10-12T04:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1358021#M8638</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189409"&gt;@xuedongyang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope that you are doing well!&lt;/P&gt;
&lt;P&gt;From the below snapshot . In the green&amp;nbsp;highlighted area ,&amp;nbsp; &amp;nbsp;I think that everything is going ok.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_0-1634658394456.png" style="width: 697px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/159535i8DE5330CB3974148/image-dimensions/697x338?v=v2" width="697" height="338" role="button" title="diego_charles_0-1634658394456.png" alt="diego_charles_0-1634658394456.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But ,&amp;nbsp; as I understand , the assignation &lt;STRONG&gt;uint16_t&amp;nbsp; &amp;nbsp;real&lt;/STRONG&gt; and&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;uint16_t&amp;nbsp;imag&lt;/STRONG&gt;&amp;nbsp; (members of your scratch_b0 structure )&amp;nbsp; is not as expected. Let me know if otherwise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you&amp;nbsp; let us see how the structures&amp;nbsp; are defined (red area )? This to&amp;nbsp; &amp;nbsp;check and try to replicate the situation more effectively.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the compiler give you any warning on this?&lt;/P&gt;
&lt;P&gt;I would recommend , to check if you need any cast ,&amp;nbsp; during the &lt;STRONG&gt;real&lt;/STRONG&gt; and &lt;STRONG&gt;imag&lt;/STRONG&gt; assignments.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diego.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 16:01:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1358021#M8638</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-10-19T16:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1359143#M8643</link>
      <description>&lt;P&gt;Thanks, Diego, for your help.&lt;/P&gt;&lt;P&gt;Please find the attached screen shot (capture1.png) for the structure definition. I think that the important thing is the definition of cfixed16_t. I am not sure which one (capture2.png and capture3.png) is the real definitions for cfixed16_t.&lt;/P&gt;&lt;P&gt;Maybe you can guide me if the definition is right and if the definition would cause the problem we observed.&lt;/P&gt;&lt;P&gt;BTW, I don't see any compiling warnings for this.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 03:42:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1359143#M8643</guid>
      <dc:creator>xuedongyang</dc:creator>
      <dc:date>2021-10-21T03:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1359149#M8644</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189409"&gt;@xuedongyang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply!&lt;/P&gt;
&lt;P&gt;Interesting! What if you go back to here ,&amp;nbsp;&amp;nbsp;define temp value arrays as fixed16_t&amp;nbsp; and test again?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_1-1634788378764.png" style="width: 616px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/159720i3CBC59261018B979/image-dimensions/616x271?v=v2" width="616" height="271" role="button" title="diego_charles_1-1634788378764.png" alt="diego_charles_1-1634788378764.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Maybe the problem is an actual&amp;nbsp; difference in the data type, as you mention with the fixed16_t .&amp;nbsp; and the compiler can not see this. But during in assembly, the data is written to &lt;STRONG&gt;img&lt;/STRONG&gt; and &lt;STRONG&gt;real&amp;nbsp;&lt;/STRONG&gt; in special way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Diego.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 04:02:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1359149#M8644</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-10-21T04:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360264#M8647</link>
      <description>&lt;P&gt;Thanks for the advice.&lt;/P&gt;&lt;P&gt;I did an experiment for 4 types of data: float, uint16_t, uint32_t, and fixed16_t. All work as expected, except fixed16_t for assignment. See the attached screen shots.&lt;/P&gt;&lt;P&gt;Any idea why fixed16_t does not work?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 22:07:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360264#M8647</guid>
      <dc:creator>xuedongyang</dc:creator>
      <dc:date>2021-10-22T22:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360360#M8650</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189409"&gt;@xuedongyang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply&amp;nbsp; and interesting tests!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably , we still need to cast that assignation of the hex value to the fixed16_t , which is intended for fixed point arithmetic.&amp;nbsp; I have a snippet code to test, where we check by code, and not by the IDE the assignation if the fixed16_t variable was successful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/** cast asignation of data to the data type *//
fixed16_t a  =  (fixed16_t ) 0xFE ;

 /** check assignation   */ 
if ( a   =  ( (fixed16_t) (0xFE) )   )
{
  /** assignation was the expected  */ 
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;By the way, which NXP processor are you using?&lt;/P&gt;
&lt;P&gt;All the best&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diego .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 23:55:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360360#M8650</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-10-23T23:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360361#M8651</link>
      <description>&lt;P&gt;Thanks for helping.&lt;/P&gt;&lt;P&gt;By casting the number with fixed16_t type as you suggested, I still observed the same problem. Very strange....&lt;/P&gt;&lt;P&gt;BTW, we are using LA1224 with VSPA3 DSP.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Oct 2021 00:20:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1360361#M8651</guid>
      <dc:creator>xuedongyang</dc:creator>
      <dc:date>2021-10-24T00:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why uint16_t assignment does not work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1368239#M8668</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189409"&gt;@xuedongyang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to what I have found on that fixed16_t: its&lt;SPAN class="Y2IQFc"&gt;&amp;nbsp;highest bit is the sign bit, and the remaining 15 bits are data .&lt;/SPAN&gt;The data values ​​from MSB to LSB are 2^(-1) to 2^(-15), for example, 0x4000 represents 2^(-1) and 0xC000 represents -2^(-1).&lt;/P&gt;
&lt;P&gt;This seems to match the fractional q15_t data type on the ARM CMSIS DSP library. however with my project compiled on ARM GCC I have not found this problem during variable assignation.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diego_charles_0-1636437334718.png" style="width: 507px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/161613i85C30FD04A014C63/image-dimensions/507x185?v=v2" width="507" height="185" role="button" title="diego_charles_0-1636437334718.png" alt="diego_charles_0-1636437334718.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am in the&amp;nbsp; general purpose MCU area, unfortunately , I do not have the hardware and SW libraries to test on my own.&amp;nbsp; I would recommend check for any examples within your BSP drivers where this&amp;nbsp; fixed16_t&amp;nbsp; is implemented and test&amp;nbsp; the assignation using different values&amp;nbsp; than 0x1357, for example 0.5 and -0.5 . It could be that the 7FFF, you are seeing&amp;nbsp; represents an overflow to the data type. Check that the sign bit can be set.&lt;/P&gt;
&lt;P&gt;Please accept my apologies for the delay and the inconvenience.&lt;/P&gt;
&lt;P&gt;Diego.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 06:23:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Why-uint16-t-assignment-does-not-work/m-p/1368239#M8668</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2021-11-09T06:23:10Z</dc:date>
    </item>
  </channel>
</rss>

