<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Using &amp;quot;powf()&amp;quot; with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92854/using-powf-with-nrf52840-in-zephyr-environment</link><description>I&amp;#39;m attempting to use the &amp;quot;powf()&amp;quot; function in a Zephyr thread. 
 When I try to run: 
 
 LOG_INF ( &amp;quot;powf: %f&amp;quot; , powf ( 2.0f , - 8.0f )); 
 
 the result is &amp;quot;inf&amp;quot;. (Code compiles, but doesn&amp;#39;t give the correct result.) 
 
 I&amp;#39;m using nRF Connect 2.0.2 SDK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Oct 2022 10:25:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92854/using-powf-with-nrf52840-in-zephyr-environment" /><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/391152?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 10:25:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9ad4814-9291-49e3-98fb-49fe42ead7d5</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m glad you found the cause!&amp;nbsp;&lt;/p&gt;
[quote user="CktDesigner"]By the way, in the process of debugging, I thought I&amp;#39;d try upgrading from version v2.0.2 to v2.1.0...&amp;nbsp; &amp;nbsp; But evidently the device-tree definitions for all of the nrf52840 peripherals changed!&amp;nbsp; &amp;nbsp;Since I have a custom board, I&amp;#39;ll have to re-write the .dts file before I can upgrade...[/quote]
&lt;p&gt;If you get stuck doing the migration, feel free to open a new ticket.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/391007?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 13:34:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28190dfb-c57c-4403-b005-e2b0cfc283de</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;
&lt;p&gt;OK, I found the issue...&amp;nbsp; &amp;nbsp;I was missing the &amp;quot;#include &amp;lt;math.h&amp;gt;&amp;quot; statement in the file that called pow()/powf()&lt;/p&gt;
&lt;p&gt;Dumb mistake...&amp;nbsp; &amp;nbsp; &amp;nbsp;But why did it compile/run without it???&amp;nbsp; &amp;nbsp; It appears that not having the .h file still compiles/runs, but gives the wrong result.&lt;/p&gt;
&lt;p&gt;By the way, in the process of debugging, I thought I&amp;#39;d try upgrading from version v2.0.2 to v2.1.0...&amp;nbsp; &amp;nbsp; But evidently the device-tree definitions for all of the nrf52840 peripherals changed!&amp;nbsp; &amp;nbsp;Since I have a custom board, I&amp;#39;ll have to re-write the .dts file before I can upgrade...&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/390967?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:16:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f5512cf-ea50-4279-a8e2-314c593747d5</guid><dc:creator>Simon</dc:creator><description>[quote user="CktDesigner"]Yet putting this code in my application doesn&amp;#39;t seem to work:[/quote]
&lt;p&gt;I just tested the same code snippet on my end, and it worked fine.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Process: JLink.exe
*** Booting Zephyr OS build v3.0.99-ncs1-1  ***
!!!!!powf sample!!!!!!!!!!!!!!!!!!!!!!!!! 
[00:00:00.370,880] &amp;lt;inf&amp;gt; Main: pow: 0.0312 0.0312
pow: 0.0312 0.0312
pow: 0.0312 0.0312&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the sample (tested with NCS v2.0.2 and nrf52840dk_nrf52840):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0027.powf_5F00_function_5F00_v3.zip"&gt;devzone.nordicsemi.com/.../0027.powf_5F00_function_5F00_v3.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/390879?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 00:44:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:835a855c-a690-441f-adeb-b991f32e0af3</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;PS...&lt;/p&gt;
&lt;p&gt;Yet putting this code in my application doesn&amp;#39;t seem to work:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/FloatIssue1.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;yields:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/FloatIssue2.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;The prj.conf file has all of the same CONFIG statements...&lt;/p&gt;
&lt;p&gt;Not sure yet what is happening here...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/390871?ContentTypeID=1</link><pubDate>Sun, 16 Oct 2022 00:45:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3743df0f-b7ff-4e34-8306-9abdfe331b9f</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;I think the problem I was having is that I was trying to report a float through a LOG_INF call.&amp;nbsp; &amp;nbsp; It appears that different CONFIG_ statements are needed allow float values&amp;nbsp; there.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached a new .zip that shows the needed CONFIG statements for the LOG_INF (and printk).&lt;/p&gt;
&lt;p&gt;On this (and other issues), is there documentation shows what &amp;quot;CONFIG&amp;quot; statements are needed for each function (almost like the old UNIX man page, where a function is described, and then specifies what CONFIG statement(s) need to be in the prf.conf file for it to work?).&amp;nbsp; &amp;nbsp; I&amp;#39;ve spent way too many hours reading through code, trying to figure out why something won&amp;#39;t compile (or run properly) and trying to figure out what CONFIG statements are needed...&lt;/p&gt;
&lt;p&gt;Thanks!&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/powf_5F00_function_5F00_new.zip"&gt;devzone.nordicsemi.com/.../powf_5F00_function_5F00_new.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using "powf()" with nRF52840 in Zephyr environment</title><link>https://devzone.nordicsemi.com/thread/390836?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2022 16:08:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dbfea17-88e5-464e-b6fd-4fe4d3b346a5</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I was able to make&amp;nbsp;the powf function work with NCS v2.0.2 and the nRF52840 DK by adding these Kconfigs to the prj.conf file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and using this code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/zephyr.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

void main(void)
{
	printk(&amp;quot;powf sample! \n&amp;quot;);
	double n1 = 5;
    double n2 = 2;
	double res;
	res = pow(n1, n2);
	printf(&amp;quot;pow(5, 2): %.01f\n&amp;quot;, res);
	
	float n3 = 5.0;
    float n4 = 2.0;
	float res2;
	res2 = powf(n3, n4);
	printf(&amp;quot;powf(5.2): %.01f\n&amp;quot;, res2);

}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Test it out yourself:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/powf_5F00_function.zip"&gt;devzone.nordicsemi.com/.../powf_5F00_function.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>