Forums - QCA4020 Enabling floating point

2 posts / 0 new
Last post
QCA4020 Enabling floating point
matis.szilard
Join Date: 29 Jul 19
Posts: 5
Posted: Thu, 2019-11-14 03:19

Hello,

We try to use floating point calculations on a QCA4020 board, but it still crashes at double conversions.

Q1: Are the floating point calculations enabled on the QCA4020 board? If, not how can we enable it?

Best regards,

Szilard

  • Up0
  • Down0
raja_pedada
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 300
Posted: Thu, 2019-11-14 10:39
1> In order for a thread to use floating point, you must call qurt_thread_set_fp_enable(). 
For example, you can insert this before your first use of floating point in a thread: 
qurt_thread_set_fp_enable(qurt_thread_get_id(), true); 
 
2> For floating operations in some cases, NEWLIBPATH and TOOLLIBPATH need to be set as below based on your toolchain path. 
SET NEWLIBPATH=C:\Workspace\Quartz\gcc-arm-none-eabi-6-2017-q1-update-win32\arm-none-eabi\lib\thumb\v7e-m\fpv4-sp\hard 
SET TOOLLIBPATH=C:\Workspace\Quartz\gcc-arm-none-eabi-6-2017-q1-update-win32\lib\gcc\arm-none-eabi\6.3.1\thumb\v7e-m\fpv4-sp\hard 
 
 
Demo Example:
 
#include "qurt_thread.h" 
 
qurt_thread_set_fp_enable(qurt_thread_get_id(), true); 
QCLI_Printf(qcli_handle,"start of function\n"); 
float val; 
double val1 = 4, val2 = 2, val3 =1.6, result; 
char str[20]; 
 
strcpy(str, "98993489"); 
val = atof(str); 
QCLI_Printf(qcli_handle,"String value = %s, Float value = %f\n", str, val); 
 
// Character array to be parsed and end pointer
char array[] = "365.25 7.0"; 
char* pend; 
 
//storing float value 
float f1 = strtof(array, &pend); 
float f2 = strtof(pend, NULL); 
 
QCLI_Printf(qcli_handle," One year has %.2f weeks \n", f1 / f2); 
 
 
 
The result on Console is as below. 
 
Net: start of function 
Net: String value = 98993489, Float value = 98993488.000000 
Net: One year has 52.18 weeks 
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.