<?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>Issues with Floating-Point Arithmetic in nRF52832 Project using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117107/issues-with-floating-point-arithmetic-in-nrf52832-project-using-segger-embedded-studio</link><description>Recently, we started developing our new project using the nRF52832 as our controller. 
 We are using Segger Embedded Studio (5.42a) as our IDE. 
 My question is: Are there any issues while using float variable arithmetic operations in Segger Embedded</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Dec 2024 07:38:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117107/issues-with-floating-point-arithmetic-in-nrf52832-project-using-segger-embedded-studio" /><item><title>RE: Issues with Floating-Point Arithmetic in nRF52832 Project using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/513958?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 07:38:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ceca3d8b-bef8-413d-8dbc-074364354ee3</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;siltvm,&lt;/p&gt;
&lt;p&gt;No, you don&amp;#39;t need to do anything special to enable FPU. It should be enabled by default.&amp;nbsp;&lt;br /&gt;Regardless, its role is not to enable, but only to speed up floating point arithmetic. Even with FPU disabled, you should still have floating point arithmetic support.&lt;/p&gt;
&lt;p&gt;The issue is still likely in printing support.&amp;nbsp;You can enable it in Project Option, following this DevZone post:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/54685/float-value-not-getting-printed"&gt;Float value not getting printed&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733729853506v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Floating-Point Arithmetic in nRF52832 Project using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/513951?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 06:10:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da4d429c-1f1c-410c-aaee-844942332fe0</guid><dc:creator>siltvm</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/vthieu"&gt;Hieu&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;iam used printf instead of &amp;quot;NRF_LOG&amp;quot; .&lt;/p&gt;
&lt;p&gt;i will attach the code for better understanding .&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; case BLE_GAP_EVT_ADV_REPORT:
       
          {
            // Extract advertising report data
            ble_gap_evt_adv_report_t const * p_adv_report = &amp;amp;p_gap_evt-&amp;gt;params.adv_report;

            // Define the target MAC address
           // uint8_t target_mac[6] = {0xF4, 0x12, 0xFA, 0xE6, 0x4F, 0x0E};

           //if (memcmp(p_adv_report-&amp;gt;peer_addr.addr, target_mac, sizeof(target_mac)) == 0)
    
            // Log the advertising device&amp;#39;s address
             if ((p_adv_report-&amp;gt;peer_addr.addr[5] == 0xBC) &amp;amp;&amp;amp; (p_adv_report-&amp;gt;peer_addr.addr[4] == 0x57)&amp;amp;&amp;amp;(p_adv_report-&amp;gt;peer_addr.addr[3] == 0x29)&amp;amp;&amp;amp;(p_adv_report-&amp;gt;peer_addr.addr[2] == 0x00)&amp;amp;&amp;amp;(p_adv_report-&amp;gt;peer_addr.addr[1] == 0x93)&amp;amp;&amp;amp;(p_adv_report-&amp;gt;peer_addr.addr[0] == 0xDA))
         {
            NRF_LOG_INFO(&amp;quot;Device Address: %02X:%02X:%02X:%02X:%02X:%02X&amp;quot;,
                         p_adv_report-&amp;gt;peer_addr.addr[5],
                         p_adv_report-&amp;gt;peer_addr.addr[4],
                         p_adv_report-&amp;gt;peer_addr.addr[3],
                         p_adv_report-&amp;gt;peer_addr.addr[2],
                         p_adv_report-&amp;gt;peer_addr.addr[1],
                         p_adv_report-&amp;gt;peer_addr.addr[0]);
            printf(&amp;quot;Device Address: %02X:%02X:%02X:%02X:%02X:%02X\n&amp;quot;,
                   p_adv_report-&amp;gt;peer_addr.addr[5],
                   p_adv_report-&amp;gt;peer_addr.addr[4],
                   p_adv_report-&amp;gt;peer_addr.addr[3],
                   p_adv_report-&amp;gt;peer_addr.addr[2],
                   p_adv_report-&amp;gt;peer_addr.addr[1],
                   p_adv_report-&amp;gt;peer_addr.addr[0]);

            //// Log the advertising data
            //NRF_LOG_INFO(&amp;quot;Advertising Data (Length: %d):&amp;quot;, p_adv_report-&amp;gt;data.len);
          
            NRF_LOG_HEXDUMP_INFO(p_adv_report-&amp;gt;data.p_data, p_adv_report-&amp;gt;data.len);
            printf(&amp;quot;\nAdvertising Data (Length: %d): &amp;quot;, p_adv_report-&amp;gt;data.len);
            for (uint32_t i = 0; i &amp;lt; p_adv_report-&amp;gt;data.len; i++)
            {
               printf(&amp;quot;%02X &amp;quot;, p_adv_report-&amp;gt;data.p_data[i]);
            }
            printf(&amp;quot;\n&amp;quot;);
            //temp_humidity((char *)p_adv_report-&amp;gt;data.p_data);
            char ch_humidity[8];
            char temperature[8];
            printf(&amp;quot;17th pos: %02X &amp;quot;, p_adv_report-&amp;gt;data.p_data[17]);
            printf(&amp;quot;18th pos: %02X &amp;quot;, p_adv_report-&amp;gt;data.p_data[18]);
            int temp = (int)p_adv_report-&amp;gt;data.p_data[17]+ (int)(p_adv_report-&amp;gt;data.p_data[16]&amp;lt;&amp;lt; 8);
            printf(&amp;quot;temp : %d\t&amp;quot;,temp);
            int calcTempScaled = (temp * 100) / 256;
            printf(&amp;quot;calcTemp (scaled): %d.%02d\n&amp;quot;, calcTempScaled / 100, calcTempScaled % 100);
            float calcTemp = (float)temp / 256.0f;
            printf(&amp;quot;calcTemp: %.2f\n&amp;quot;, calcTemp);
            //sprintf(temperature,&amp;quot; %d.%02d&amp;quot;, calcTempScaled / 100, calcTempScaled % 100);
            //int hum = (int)p_adv_report-&amp;gt;data.p_data[19] + (int)(p_adv_report-&amp;gt;data.p_data[18]&amp;lt;&amp;lt; 8);
            float calcHum = (hum / 256.0f);
            sprintf(ch_humidity,&amp;quot;%6.1f&amp;quot;, calcHum);
           //int calcHumScaled = (hum * 100) / 256; // Scale result to represent two decimal places
           // Format humidity as a string
           //sprintf(ch_humidity, &amp;quot;%d.%02d&amp;quot;, calcHumScaled / 100, calcHumScaled % 100);

           // printf(&amp;quot;Temperature: %s &amp;#176;C\t humidity : %s\n&amp;quot;, temperature,ch_humidity);
            nrf_delay_ms(100);
          }
        }
        break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;is there any need of enabling &amp;quot;FPU&amp;quot; in seggar embedded studio . if it is needed how can i enable it ? .&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Floating-Point Arithmetic in nRF52832 Project using Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/513945?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 04:41:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f58ca4b9-d447-4d10-bb19-0e4c32cd053d</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi siltvm,&lt;/p&gt;
&lt;p&gt;There is no issue with float calculation on the nRF52832 with&amp;nbsp;nRF5 SDK v17.0.2.&amp;nbsp;The SDK version&amp;nbsp;was released and tested with SES v5.40, but 5.42a should still work.&lt;/p&gt;
&lt;p&gt;How are you printing the floating number to console? Could it be you are having the kind of issue discussed in this case&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/24030/how-to-print-floats-with-nrf_log-macros"&gt;How to print floats with NRF_LOG macros&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Can you use the debugger to check if the values of the relevant float variables were correct?&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>