<?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: Using a ACOS function</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237622#M23302</link>
    <description>&lt;P&gt;You are welcome!&lt;/P&gt;</description>
    <pubDate>Mon, 01 Mar 2021 02:09:12 GMT</pubDate>
    <dc:creator>ZhangJennie</dc:creator>
    <dc:date>2021-03-01T02:09:12Z</dc:date>
    <item>
      <title>Using a ACOS function</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1235818#M23296</link>
      <description>&lt;P&gt;Friends of Community,&lt;/P&gt;&lt;P&gt;In my current project, I need to limit a sinusoidal wave (in any point), and for this I need to use the ACOS function. I implement the next code in a S08RNA16 MCU:&lt;/P&gt;&lt;P&gt;/* Including needed modules to compile this module/procedure */&lt;BR /&gt;#include "Cpu.h"&lt;BR /&gt;#include "Events.h"&lt;/P&gt;&lt;P&gt;/* Include shared modules, which are used for whole project */&lt;BR /&gt;#include "PE_Types.h"&lt;BR /&gt;#include "PE_Error.h"&lt;BR /&gt;#include "PE_Const.h"&lt;BR /&gt;#include "IO_Map.h"&lt;/P&gt;&lt;P&gt;#include &amp;lt;math.h&amp;gt;&lt;/P&gt;&lt;P&gt;/* User includes (#include below this line is not maintained by Processor Expert) */&lt;/P&gt;&lt;P&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;/* Write your local variable definition here */&lt;BR /&gt;&lt;BR /&gt;float x, y;&lt;BR /&gt;&lt;BR /&gt;/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&lt;BR /&gt;PE_low_level_init();&lt;BR /&gt;/*** End of Processor Expert internal initialization. ***/&lt;BR /&gt;&lt;BR /&gt;x = 0.0;&lt;BR /&gt;y = cos(x);&lt;BR /&gt;&lt;BR /&gt;x = _M_PI/2;&lt;BR /&gt;y = cos(x);&lt;/P&gt;&lt;P&gt;x = _M_PI;&lt;BR /&gt;y = cos(x);&lt;BR /&gt;&lt;BR /&gt;x = 2*_M_PI;&lt;BR /&gt;y = cos(x);&lt;BR /&gt;&lt;BR /&gt;x = 1.0;&lt;BR /&gt;y = acos(x);&lt;BR /&gt;&lt;BR /&gt;x = 0.9;&lt;BR /&gt;y = acos(x);&lt;/P&gt;&lt;P&gt;x = -1.0;&lt;BR /&gt;y = acos(x);&lt;/P&gt;&lt;P&gt;/* Write your code here */&lt;BR /&gt;/* For example: for(;;) { } */&lt;BR /&gt;for (;;)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/*** Don't write any code pass this line, or it will be deleted during code generation. ***/&lt;BR /&gt;/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;#ifdef PEX_RTOS_START&lt;BR /&gt;PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt;#endif&lt;BR /&gt;/*** End of RTOS startup code. ***/&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;for(;;){}&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;When the control of program reach the point to calculate the ACOS of 0.9, the Simulator of CodeWarrior 11.1 goes to this screen (rtshc08.c) and stop (the program does not calculate the ACOS for that value):&lt;/P&gt;&lt;P&gt;#pragma NO_EXIT&lt;BR /&gt;static void _FADD_Common(void) {&lt;BR /&gt;asm {&lt;BR /&gt;JSR _UNPACK_k_to_K;&lt;BR /&gt;JSR _UNPACK_j_to_L;&lt;BR /&gt;JSR _FADD_K_is_K_plus_L;&lt;BR /&gt;JSR F_NORMK;&lt;BR /&gt;_SRET&lt;BR /&gt;JSR _PACK_K_to_k; /* returns itself */&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;My question is: Why am I finding this problem for a valid number (0.9) for the ACOS function?&lt;/P&gt;&lt;P&gt;I appreciate an orientation for solve this problem.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 15:09:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1235818#M23296</guid>
      <dc:creator>hpgorobr</dc:creator>
      <dc:date>2021-02-24T15:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ACOS function</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237179#M23298</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;hpgorobr&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Your problem is cased by stack over flow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The default stack size is 0x80. for example, increase it to 0x200, regenerate code and build, this can fix the issue&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ZhangJennie_0-1614329078296.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/138219iC820CD77AB8324F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ZhangJennie_0-1614329078296.png" alt="ZhangJennie_0-1614329078296.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Besides, HCS08RNA16 on chip RAM is limit, only&amp;nbsp;&lt;SPAN&gt;4kB. Wile math lib functions like you are you using are memory consuming, If your application has many&amp;nbsp;trigonometric function computation, I suggest you creating a&amp;nbsp;trigonometric function table rather than call math lib functions directly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jun Zhang&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 08:59:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237179#M23298</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2021-02-26T08:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ACOS function</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237419#M23300</link>
      <description>&lt;P&gt;Hello Jun,&lt;/P&gt;&lt;P&gt;You are right, I change the Stack position using the next sentence and the program compile OK work OK:&lt;/P&gt;&lt;P&gt;// Setting of Stack Pointer in the end of RAM&lt;BR /&gt;__asm LDHX #RAM_LAST+1 ; // point one past RAM&lt;BR /&gt;__asm TXS ; // SP&amp;lt;-(H:X-1)&lt;/P&gt;&lt;P&gt;Thank you very much Jun for your help.&lt;BR /&gt;Sincerely&lt;BR /&gt;Horacio Gorosito&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 18:53:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237419#M23300</guid>
      <dc:creator>hpgorobr</dc:creator>
      <dc:date>2021-02-26T18:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using a ACOS function</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237622#M23302</link>
      <description>&lt;P&gt;You are welcome!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 02:09:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Using-a-ACOS-function/m-p/1237622#M23302</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2021-03-01T02:09:12Z</dc:date>
    </item>
  </channel>
</rss>

