<?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: Reconstructing Frac16 Values in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214311#M6121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there Ipa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, I must apologise! I figured this little tidbit out the morning after I posted my last message. So, I'm happy to say, I have it all working. I just neglected to post about it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jun 2011 07:03:00 GMT</pubDate>
    <dc:creator>Law</dc:creator>
    <dc:date>2011-06-22T07:03:00Z</dc:date>
    <item>
      <title>Reconstructing Frac16 Values</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214308#M6118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gday,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a bit new to the Freescale embedded world. I have a 56F8037 Dev board that I have been playing around with for a while now. Well, I am trying to get some serial data out of my board. (I havent been using Freemaster as part of my messings about include a linux host that talks to the board). Anywho, I have serial all up and going, but my problem is during the breaking down of Frac16 values for transmission and reconstruction at the other end.&lt;/P&gt;&lt;P&gt;In essence, I simply want to push out some Frac16 variables over serial so I can view them on my linux host.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the DSC side of things, I have two defines, they are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define BYTE_L(x) ((x) &amp;amp; (unsigned short)0xFF)&lt;/P&gt;&lt;P&gt;#define BYTE_H(x) ((x &amp;gt;&amp;gt; 8) &amp;amp; (unsigned short)0xFF)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then deconstruct a frac16 and send it over serial using the above defines, IE&lt;/P&gt;&lt;P&gt;sendser(BYTE_H(frac16Val));&lt;/P&gt;&lt;P&gt;sendser(BYTE_L(frac16Val));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the PC side of things, I load the recieved data into a buffer then attempt to reconstruct it. I think this is where the problems arise!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a function on the PC side that I put the values from the buffer through to reconstruct them in to floating point versions of the Frac16. In theory, the floats should then contain some value from -1 to 0.9999999&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;float build_float(char upper, char lower)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float float_val;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return float_val = ((float)((((char)upper) &amp;lt;&amp;lt; 8) | (char)lower) / 32768);&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ie Resultant_Float = build_float(ser_buffer[0], ser_buffer[1]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I am not getting expected values back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone please cast an eye over this and let me know if I am on the right track?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jun 2011 14:31:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214308#M6118</guid>
      <dc:creator>Law</dc:creator>
      <dc:date>2011-06-11T14:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reconstructing Frac16 Values</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214309#M6119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would just like to post a follow up to this.&lt;/P&gt;&lt;P&gt;I was messing around and created 2 programs that sent static info from the DSC to my PC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All it does is send -1 to 1 in increments of 0.1 to the PC, which attempts to reinterpret&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the output:&lt;/P&gt;&lt;P&gt;[ -1.000000 ]&lt;BR /&gt;[ -0.001556 ]&lt;BR /&gt;[ -0.003113 ]&lt;BR /&gt;[ -0.699982 ]&lt;BR /&gt;[ -0.599976 ]&lt;BR /&gt;[ -0.500000 ]&lt;BR /&gt;[ -0.001556 ]&lt;BR /&gt;[ -0.003113 ]&lt;BR /&gt;[ -0.199982 ]&lt;BR /&gt;[ -0.099976 ]&lt;BR /&gt;[ 0.000000 ]&lt;BR /&gt;[ -0.001587 ]&lt;BR /&gt;[ -0.003143 ]&lt;BR /&gt;[ 0.299988 ]&lt;BR /&gt;[ 0.399994 ]&lt;BR /&gt;[ 0.500000 ]&lt;BR /&gt;[ -0.001587 ]&lt;BR /&gt;[ -0.003143 ]&lt;BR /&gt;[ 0.799988 ]&lt;BR /&gt;[ 0.899994 ]&lt;BR /&gt;[ -0.000031 ]&lt;BR /&gt;﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can see that it is correctly converting some of the values, IE -1, -.7, -.6, -,5 etc, but you can see it just screws up on some of the values!&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jun 2011 15:15:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214309#M6119</guid>
      <dc:creator>Law</dc:creator>
      <dc:date>2011-06-11T15:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reconstructing Frac16 Values</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214310#M6120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You must take into account the endianess of two different micros:&lt;/P&gt;&lt;P&gt;on PC is little endian, so you must send in order sender(BYTE_LSB), sender(BYTE_MSB).&lt;/P&gt;&lt;P&gt;Or take into account that on PC side and re-assemble correctly the word.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;IPA&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jun 2011 14:45:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214310#M6120</guid>
      <dc:creator>ipa</dc:creator>
      <dc:date>2011-06-19T14:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reconstructing Frac16 Values</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214311#M6121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there Ipa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, I must apologise! I figured this little tidbit out the morning after I posted my last message. So, I'm happy to say, I have it all working. I just neglected to post about it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Laurence&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 07:03:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Reconstructing-Frac16-Values/m-p/214311#M6121</guid>
      <dc:creator>Law</dc:creator>
      <dc:date>2011-06-22T07:03:00Z</dc:date>
    </item>
  </channel>
</rss>

