mikroC Pro dsPIC 6.2.1 , floating point calculations issue

General discussion on mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

mikroC Pro dsPIC 6.2.1 , floating point calculations issue

#1 Post by KaranSoin » 25 Jan 2016 01:13

Hello, I am trying to compile the following C code and the compiler is throwing a bunch of errors. It seem to be something to do with floating point calculations. Any setting I have missed or any library have I forgotten to include ? Any insight is greatly appreciated.

Regards
Karan Soin


Code: Select all

#define VREF            2.45
#define R1_VBAT         100000L
#define R2_VBAT         100000L
#define R1_POWER_IN     1500000L
#define R2_POWER_IN     100000L
#define R1_VCC          180000L
#define R2_VCC          150000L
#define R1_CURRENT      8200L
#define R2_CURRENT      10000L

#define SENSITIVITY     0.066
.
.
.
.
.

Code: Select all

     unsigned int CURRENT_RAW;
     unsigned int VBAT_RAW;
     unsigned int POWER_VOLTAGE_RAW;
     unsigned int VCC_VOLTAGE_RAW;


      float CURRENT;
      float VBAT;
      float POWER_VOLTAGE;
      float VCC_VOLTAGE;

(Following fragment is the trouble creator part of the code. Disabling this, the project compiles fine)

Code: Select all

              VBAT          =  ( ( VBAT_RAW          / 1024.0 )  *  VREF    )    *    (   ( R1_VBAT     + R2_VBAT     )   /   R2_VBAT      );
              POWER_VOLTAGE =  ( ( POWER_VOLTAGE_RAW / 1024.0 )  *  VREF    )    *    (   ( R1_POWER_IN + R2_POWER_IN )   /   R2_POWER_IN  );
              VCC_VOLTAGE   =  ( ( VCC_VOLTAGE_RAW   / 1024.0 )  *  VREF    )    *    (   ( R1_VCC      + R2_VCC      )   /   R2_VCC       );
              CURRENT       =  ( ( CURRENT_RAW       / 1024.0 )  *  VREF    )    *    (   ( R1_CURRENT  + R2_CURRENT  )   /   R2_CURRENT   ) / SENSITIVITY;
following are the errors and warnings

Code: Select all

0 1 mikroCdsPIC.exe -MSF -DBG -pP24FJ256GB106 -C -DL -SSA -O11111114 -fo32 -N"I:\Projects\Coulomb Counter\Firmware\MyProject.mcpds" -SP"C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for dsPIC\Defs\" -SP"C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for dsPIC\Uses\" -SP"I:\Projects\Coulomb Counter\Firmware\" -IP"I:\Projects\Coulomb Counter\Firmware\" "Coulomb Counter.c" "RTC.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Conversions.mcl" "__Lib_Sprintf.mcl" "__Lib_Time.mcl" "__Lib_Sound.mcl" "__Lib_ADC_1_p24FJ256_GA_GB_110.mcl" "__Lib_I2C_123_p24fj.mcl" "__Lib_UART_1234_p24_p33.mcl" "__Lib_PPS_p24FJ256_GA_GB_110_DPC64B.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl"  
0 121 Loading...  
0 122 Compilation Started def.h
99 1163 Variable 'i' has been declared, but not used Coulomb Counter.c
100 1163 Variable 'c' has been declared, but not used Coulomb Counter.c
101 1163 Variable 'dec' has been declared, but not used Coulomb Counter.c
208 123 Compiled Successfully Coulomb Counter.c
108 1164 Variable 'VCC_VOLTAGE_RAW' has been eliminated by optimizer Coulomb Counter.c
208 324 Undeclared identifier '__long2float' in expression Coulomb Counter.c
208 324 Undeclared identifier '__div_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__long2float' in expression Coulomb Counter.c
208 324 Undeclared identifier '__div_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__long2float' in expression Coulomb Counter.c
208 324 Undeclared identifier '__div_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__long2float' in expression Coulomb Counter.c
208 324 Undeclared identifier '__div_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__mul_fp' in expression Coulomb Counter.c
208 324 Undeclared identifier '__div_fp' in expression Coulomb Counter.c
0 122 Compilation Started def.h
191 1163 Variable 'rawtime' has been declared, but not used RTC.c
192 1163 Variable 'timeinfo' has been declared, but not used RTC.c
424 123 Compiled Successfully RTC.c
126 1164 Variable 'epoch' has been eliminated by optimizer RTC.c
189 1164 Variable 'BCD_ss' has been eliminated by optimizer RTC.c
0 102 Finished (with errors): 25 Jan 2016, 06:26:06 MyProject.mcpds

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: mikroC Pro dsPIC 6.2.1 , floating point calculations iss

#2 Post by filip » 25 Jan 2016 10:15

Hi,

Did you enable the case sensitivity ?

Regards,
Filip.

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: mikroC Pro dsPIC 6.2.1 , floating point calculations iss

#3 Post by KaranSoin » 25 Jan 2016 11:19

Hello Filip,
Yes, I did enable case sensitivity

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: mikroC Pro dsPIC 6.2.1 , floating point calculations iss

#4 Post by filip » 26 Jan 2016 15:57

Hi,

Please, disable it and it should work now, I will report this issue to our developers.

I apologize for the inconvenience caused by this.

Regards,
Filip.

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: mikroC Pro dsPIC 6.2.1 , floating point calculations iss

#5 Post by KaranSoin » 26 Jan 2016 16:06

Thankyou Filip, regards

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 General”