<?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>8-bit MicrocontrollersのトピックRe: problem with C math lib.</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132390#M3039</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can You send me the square root routine? Thanks in advance &lt;A href="mailto:info@vn-amps.com.ar" rel="nofollow" target="_blank"&gt;info@vn-amps.com.ar&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Dec 2009 05:19:53 GMT</pubDate>
    <dc:creator>ultrasniper</dc:creator>
    <dc:date>2009-12-29T05:19:53Z</dc:date>
    <item>
      <title>problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132381#M3030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I am using codewarrior development studio for HC(S)08 special editon(V3.1) to develop a proj.&amp;nbsp;used by&amp;nbsp; MC68HC908JL3.&lt;/DIV&gt;&lt;DIV&gt;when i use #include &amp;lt;math.h&amp;gt;&amp;nbsp; and make it, the errors &amp;amp; warrnings window indicates that link error:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;symbol&amp;nbsp; sqrt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in file ...\main.c.o is undefined and&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;symbol&amp;nbsp; _DUFLOAT in file ...\main.c.o is undefined.&lt;BR /&gt;i wonder i can use C math lib.? and if i want to calcaulate sqrt(x), how to do it?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Message Edited by hotdog on &lt;SPAN class="date_text"&gt;04-13-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;02:25 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Apr 2006 14:23:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132381#M3030</guid>
      <dc:creator>hotdog</dc:creator>
      <dc:date>2006-04-13T14:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132382#M3031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Did you specify you intend to use math library when you created the project?&lt;BR /&gt;Did you create your project using the project wizard?&lt;/P&gt;&lt;P&gt;Default settings for HC08 doe not include floating point arithmetic support as this generate a big code overhead.&lt;/P&gt;&lt;P&gt;I would recommend you to create a project from&amp;nbsp;the wizard&amp;nbsp;and specify in the C/C++ Panel (the last panel when you create a project) that you want to use floating point arithmetic.&lt;BR /&gt;Then add your source file to the project and it should be working.&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Apr 2006 15:26:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132382#M3031</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-04-13T15:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132383#M3032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I believe you will need to change the C libarary file that is linked with the project. To use floating point math you must use the correct library file. This is automatically selected when you use the project wizard to setup a new project.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Apr 2006 17:40:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132383#M3032</guid>
      <dc:creator>Technoman64</dc:creator>
      <dc:date>2006-04-13T17:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132384#M3033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Hotdog:&lt;BR /&gt;&lt;BR /&gt;Do you need integer Square-root or floating point Square-root?&lt;BR /&gt;&lt;BR /&gt;I have an old 24-bit integer square-root routine that was originally written for HC05. It will run on HC08 as is, but there is probably room to optimize it for HC08. Let me know if you need it.&lt;P&gt;Message Edited by rocco on &lt;SPAN class="date_text"&gt;04-13-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;03:30 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Apr 2006 04:11:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132384#M3033</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-04-14T04:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132385#M3034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;thanks for CrasyCat,Technoman64 and rocco's help!&lt;BR /&gt;as your directions, i just created a project by&amp;nbsp;wizard to use floating point arithmetic and worte a prog. as follows:&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;#include &amp;lt;hidef.h&amp;gt;&lt;BR /&gt;#include &amp;lt;MC68HC908JL3.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;&amp;nbsp;unsigned char c;&lt;BR /&gt;&amp;nbsp;float y;&lt;BR /&gt;void main(void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;y=sqrt(16);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;c=16;&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;after&amp;nbsp;passed compile and make, &amp;nbsp;i run "start" or run to "c=16;" line, True-Time Simulaor &amp;amp; Real-Time Debugger window indicates that program stops at float frexpf (float x, int *i){...} in source window and appears "attempt to push or pop with sp out of allowed range" in command window.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;i wonder how i can get it through?additionally i want to calcaulate an integer square-root in the proj., i would be very appreciated if rocco would like to send the 24-bit integer square-root routine to my emailbox (&lt;A href="mailto:xiaojunj_sh@yahoo.com.cn" rel="nofollow" target="_blank"&gt;xiaojunj_sh@yahoo.com.cn&lt;/A&gt;).&lt;/DIV&gt;&lt;P&gt;Message Edited by hotdog on &lt;SPAN class="date_text"&gt;04-14-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;01:25 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Message Edited by hotdog on &lt;SPAN class="date_text"&gt;04-14-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;01:26 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Apr 2006 13:19:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132385#M3034</guid>
      <dc:creator>hotdog</dc:creator>
      <dc:date>2006-04-14T13:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132386#M3035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Did you try to increase the stack size (in the prm file)?&lt;BR /&gt;My guess: you did run out of stack space.&lt;BR /&gt;&lt;BR /&gt;If you only need an integral sqare root, then dont use the ANSI floaing point sqrt function. It is way too expensive, especially for a small chip like a JL3.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Apr 2006 08:03:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132386#M3035</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-04-15T08:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132387#M3036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Hotdog:&lt;BR /&gt;&lt;BR /&gt;I sent you two files. One of them contains the square-root subroutine, but it uses some macros and definitions from my 8/16/24/32-bit integer math library. So I included the library as well.&lt;BR /&gt;&lt;BR /&gt;You probably don't need much from the library, but all of my math routines use a "pseudo-accumulator", which is actually just four bytes of ram, defined as ACCUM3, ACCUM2, ACCUM1 and ACCUM0. These are defined at the beginning of the math library.&lt;BR /&gt;&lt;BR /&gt;The square-root routine is not an approximation, it produces an exact root with truncation (any fractional portion of the root is not computed). It uses no multiplies or divides, just shift and subtract (but a LOT of shifts). I could easily be converted to 32-bit or 16-bit, as well as optimized for HC08.&lt;BR /&gt;&lt;BR /&gt;Hope it helps.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Apr 2006 12:04:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132387#M3036</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-04-15T12:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132388#M3037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Sir,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I had the same problem that can't compile the file using math.h as i didn't set the project to floating point. I tried using the wizard and enable the floating point support, it is working. However, when i try to do the same things by enabling the floating point option in one of the SMAC project. It doesn't work. I double check the Target Setting Panel &amp;gt; Compiler for HC08 the '-Fd' is included in the setting already but i still can't compile the project. Am i doing the right way to enable the floating point support for my existing project that doesn't have floating point support initially when i create it. Hope to hear some advice from you all.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Oct 2006 14:18:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132388#M3037</guid>
      <dc:creator>khtan</dc:creator>
      <dc:date>2006-10-17T14:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132389#M3038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to use the function exp and log but so far the simulator gives a message "Error: Attempt to push or pop with SP out of allowed range". I've changed the SP initial value, then there is an error in the calculation. Also defined _MSL_FLOATING_POINT 1 but not worked yet. Any help would be appreciated. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2009 11:31:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132389#M3038</guid>
      <dc:creator>Capitao_Caverna</dc:creator>
      <dc:date>2009-07-17T11:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132390#M3039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can You send me the square root routine? Thanks in advance &lt;A href="mailto:info@vn-amps.com.ar" rel="nofollow" target="_blank"&gt;info@vn-amps.com.ar&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Dec 2009 05:19:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132390#M3039</guid>
      <dc:creator>ultrasniper</dc:creator>
      <dc:date>2009-12-29T05:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132391#M3040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Ultrasniper,&lt;BR /&gt;&lt;BR /&gt;I emailed some files that should get you a square-root routine for the S08.&lt;BR /&gt;&lt;BR /&gt;The square-root routine, "SQUAROOT.SA5", was written for the HC05 many years ago. I never optimized it for the S08, because I didn't need it anymore.&lt;BR /&gt;&lt;BR /&gt;It uses macros from my math library, so I included the original HC05 version "MATH.SA5", and my updated S08 version "Math.sa8". You should be able to get a working square-root from there.&lt;BR /&gt;&lt;BR /&gt;You may have to change the file extensions (Codewarrior may insist on '.asm') and update the syntax (Motorola used to modify the assembler syntax every few years) to get is to assemble. It was originally written for Motorola's PASM assembler.&lt;BR /&gt;&lt;BR /&gt;Good Luck.&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by rocco on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-12-29&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:40 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Dec 2009 04:38:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132391#M3040</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2009-12-30T04:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: problem with C math lib.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132392#M3041</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;I pulled this C function from an earlier thread.&amp;nbsp; It is capable of handling a 16-bit integer value, and returning the square root to the nearest integer.&amp;nbsp; It uses the Newton algorithm where each calculation within the do-while loop provides a closer approximation to the square root value.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;word sqrt( word val)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; word temp, x = 4096;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; do {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = (val/x + x + 1)/2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; } while (x != temp);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return x;&lt;BR /&gt;}&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>Wed, 30 Dec 2009 11:15:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/problem-with-C-math-lib/m-p/132392#M3041</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-12-30T11:15:43Z</dc:date>
    </item>
  </channel>
</rss>

