AnsweredHot!Convert to float giving me warnings below

Author
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
2018/11/08 00:47:40 (permalink)
1 (1)

Convert to float giving me warnings below

I'm using pic18f45k22 with xc8 compiler.
Inside a timer interrupt i'm using a convert to float. Then i'm getting in compiler warnings below. Should i ignore them?
 G_IN.Value is a float variable.
 
uint16_t EncoderFlag;

void IncreaseCounter()//This is a timer interrupt routine which interrupts every 1'' second
{
    G_IN.Value=(float)EncoderFlag*60.0f;
     EncoderFlag=0;
}
 
void FumeEncoder()//This is an Int0 pin interrupt routine
{
EncoderFlag+=1;
}

 
I'm getting this warnings 
C:\Program Files (x86)\Microchip\xc8\v1.45\sources\common\Umul16.c:15: advisory: (1510) non-reentrant function "___wmul" appears in multiple call graphs and has been duplicated by the compiler
C:\Program Files (x86)\Microchip\xc8\v1.45\sources\common\float.c:62: advisory: (1510) non-reentrant function "___ftpack" appears in multiple call graphs and has been duplicated by the compiler
C:\Program Files (x86)\Microchip\xc8\v1.45\sources\common\fttol.c:44: advisory: (1510) non-reentrant function "___fttol" appears in multiple call graphs and has been duplicated by the compiler
C:\Program Files (x86)\Microchip\xc8\v1.45\sources\common\lwtoft.c:28: advisory: (1510) non-reentrant function "___lwtoft" appears in multiple call graphs and has been duplicated by the compiler

 
 
post edited by Dimitris - 2018/11/08 01:29:11
#1
qhb
Superb Member
  • Total Posts : 7891
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 01:09:48 (permalink)
+2 (2)
"Advisories" are NOT "Warnings.
The compiler is just letting you know that it has had to duplicate some of the floating point code because it is used both inside and outside the interrupt service.
This will work, it just makes your code a bit bigger.
 
That said, it is generally a bad idea to do any floating point calculations inside an ISR on a small processor. Do you really have no choice?
 
#2
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 01:25:03 (permalink)
0
I'm using a motor encoder calculation. Every time i have interrupt in int0 pin, i increase my endoderFlag +1;
And then every time i get 1 second interrupt in timer, i multiply it with 60 for getting how many turns my motor has.
I can't think any other way for doing this, if there is any better idea please let me know...
post edited by Dimitris - 2018/11/08 01:29:36
#3
qhb
Superb Member
  • Total Posts : 7891
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 01:43:24 (permalink)
+1 (1)
Set a flag in your one second timer interrupt, and get your non interrupt code to do the calculation every time it sees the flag set.
 
#4
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 02:03:17 (permalink)
0
Yes but inside the while it will not be exactly one second...Cause  inbetween interrupt and flag bit maybe there will exist dealys and other fuctions....
#5
qhb
Superb Member
  • Total Posts : 7891
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 02:05:35 (permalink) ☼ Best Answerby Dimitris 2018/11/08 02:13:12
+4 (4)
There are other things going in that you have not revealed then.
I still fail to see why you need to use floating point to multiply what appears to be an integer by 60.
You can nearly always do things better using integer calculations, floating point is often the lazy way to do it.
 
#6
NKurzman
A Guy on the Net
  • Total Posts : 16662
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 06:45:05 (permalink)
+3 (3)
You do realize how long floating point operations take? It means that is a very long interrupt.
#7
andersm
Super Member
  • Total Posts : 2485
  • Reward points : 0
  • Joined: 2012/10/07 14:57:44
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/08 08:27:38 (permalink)
+2 (4)
Why is this posted in the MPLAB X forum?
#8
mlp
boots too small
  • Total Posts : 630
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: previously Microchip XC8 team
  • Status: offline
Flagged as Spam (1)
Re: Convert to float giving me warnings below 2018/11/08 12:20:04 (permalink)
+3 (5)
andersmWhy is this posted in the MPLAB X forum?

Because the OP is either an imbecile or inexperienced.

Mark (this opinion available for hire)
#9
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 04:57:03 (permalink)
0 (2)
mark.pappin
andersmWhy is this posted in the MPLAB X forum?

Because the OP is either an imbecile or inexperienced.


Does it going for me?
#10
rodims
Super Member
  • Total Posts : 1377
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 05:32:04 (permalink)
+4 (6)
Anyway, you had two options to choose from ;-) 
So why don't YOU simply answer andersms question ?
 
You posted all of your last 30 threads (with one single exception) in the MpLabX forum.
Most of them do not relate to MpLabX at all.
There are many many sub-forums where experienced members (with e.g. your 297 posts) would place their question depending on the individual topic.  
But for some unknown reason, you post everything under MpLabX. 
That was the question.
 
#11
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 06:04:12 (permalink)
-3 (3)
Ok my wrong. But there is not option to move my post. Also some moderator can move it too. But it is not right to speak with this words(imbecile) in a community forum.  Fix forum, so can member to move  posts  in other category. Also i have accept answer 4 posts before
post edited by Dimitris - 2018/11/09 06:06:24
#12
rodims
Super Member
  • Total Posts : 1377
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 06:33:06 (permalink)
+2 (2)
No moderator will do the work for you to move posts around.
And still you did not answer why you used MpLabX for all your posts, this was not a one time issue.
 
But thanks for the down-vote, what exactly raised your displeasure ?
 
#13
Jim Nickerson
User 452
  • Total Posts : 5578
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 06:56:49 (permalink) ☄ Helpfulby Dimitris 2018/11/09 07:18:45
+4 (4)
Please try to avoid marking posts as spam that clearly are not spam.
If you do not like a post then please do give it a thumbs down.
It is possible to start a post in a forum and place a link to a post in the wrong forum, no moderator involvement is required.
 
#14
Dimitris
Super Member
  • Total Posts : 303
  • Reward points : 0
  • Joined: 2017/11/03 10:29:26
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 07:18:39 (permalink)
0
Thank you
#15
mlp
boots too small
  • Total Posts : 630
  • Reward points : 0
  • Joined: 2012/09/10 15:12:07
  • Location: previously Microchip XC8 team
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 11:15:54 (permalink)
+1 (1)
dimis1989
it is not right to speak with this words(imbecile) in a community forum

An interesting assertion.
I likewise assert that it is not right to flag as spam a posting which is not in fact spam but directly answers a question which was asked.
 
So far just one of those assertions has been supported by forum users other than those making them.

Mark (this opinion available for hire)
#16
NKurzman
A Guy on the Net
  • Total Posts : 16662
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Convert to float giving me warnings below 2018/11/09 11:53:24 (permalink)
+2 (2)
As a Note this Forum is mostly Un-moderated.
#17
Jump to:
© 2018 APG vNext Commercial Version 4.5