<?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>Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68740/floating-point-exception-on-nrf9160</link><description>Hi, 
 I have a problem with floating point types on nrf9160. 
 I get an exception when I get to a simple floating point assinment: 
 void f(int i) 
 { 
 float x; 
 x = (float)i; 
 } 
 The disasemmbly is: vldr s15, r0 
 
 here is my prj.conf 
 
 CONFIG_PRINTK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Dec 2020 13:50:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68740/floating-point-exception-on-nrf9160" /><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/282690?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 13:50:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4f63c79-be8b-400b-8fe4-1c8faff51dbd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Danny,&lt;/p&gt;
&lt;p&gt;Are you getting a fault exception then? The FPU exception has to be enabled explicitly by writing to the NVIC registers and it should be disabled by default.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/282686?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 13:44:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b4377ca-f857-4014-8379-7568d0cba31d</guid><dc:creator>Danny Zadok</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;No. I did not&amp;nbsp;&lt;span&gt;&amp;nbsp;enable the FPU exception handler in my app.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I do I enable/disable it? Please let me know if it is enabled.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/282637?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 11:27:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f9b6297-8112-490f-a310-5c8254e03a1c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Danny,&lt;/p&gt;
&lt;p&gt;Have you enabled the FPU exception handler in your app? In that case, I think I&amp;#39;ve misunderstood the problem. I thought the float instruction was causing a fault exception at first. Assuming it&amp;#39;s indeed a FPU exception, can you read the control register to check what the reason for the exception is (&lt;a href="https://developer.arm.com/documentation/100235/0100/The-Cortex-M33-Peripherals/Floating-Point-Unit/Floating-point-Status-Control-Register"&gt;Floating-point Status Control Register&lt;/a&gt;)? Most likely it is going to be the IXC bit, which indicate that the result of a FP computation has been rounded. There is a similar thread about this here: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/57519/mask-fpu-ixc-exception"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/57519/mask-fpu-ixc-exception&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/282518?ContentTypeID=1</link><pubDate>Mon, 30 Nov 2020 16:43:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27d47aaa-be27-4ae3-a0b5-938393deb0e9</guid><dc:creator>Danny Zadok</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;No. I do not do floating point operation from multiple threads. Only from one thread.&lt;/p&gt;
&lt;p&gt;Besides, I did add this&amp;nbsp;&lt;span&gt;ONFIG_FPU_SHARING=y&amp;nbsp; config parameter, but it did not help.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The only workaround&amp;nbsp;was to disable the compiler optimizations with&amp;nbsp;CONFIG_NO_OPTIMIZATIONS=y&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Danny&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/281971?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 08:59:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:388a4ae8-2492-4366-95c9-851e7480a749</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Danny,&lt;/p&gt;
&lt;p&gt;Are you doing float operations from multiple threads by any chance? The help text for CONFIG_FPU says that:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;&amp;quot;When this option is enabled, by default, threads may use the floating point registers only in an exclusive manner, and this usually means that only one thread may perform floating point operations.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;If it is necessary for multiple threads to perform concurrent floating point operations, the “FPU register sharing” option must be enabled to preserve the floating point registers across context switches.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Please try to build with CONFIG_FPU_SHARING=y and see if it makes any difference.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Floating point exception on nrf9160</title><link>https://devzone.nordicsemi.com/thread/281708?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 07:32:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e9e96e0-c28c-4147-9c63-94d1897116e1</guid><dc:creator>Danny Zadok</dc:creator><description>&lt;p&gt;Additional information:&lt;/p&gt;
&lt;p&gt;If I disable the compiler optimizations in prj.conf by&lt;/p&gt;
&lt;p&gt;CONFIG_NO_OPTIMIZATIONS=y&lt;/p&gt;
&lt;p&gt;It stops happening.&lt;/p&gt;
&lt;p&gt;But I need the optimizations.&lt;/p&gt;
&lt;p&gt;Does any one knows why GCC optimizations causes exceptions?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Danny&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>