View previous topic :: View next topic |
Author |
Message |
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
Re-entrancy warning |
Posted: Tue Jun 28, 2016 12:37 pm |
|
|
Hi, Having just moved to v5 compiler, my code which compiled and worked on v3 is giving me the following warning:
"interrupts disabled during call to prevent re-entrancy (@ADDFF)"
What is $ADDFF? I can find no mention of it and therefore I don't know where to look to get rid of the warning. It saya it is at the last closing brace of the last function in the program!! Not too helpful!
Any help most appreciated.
The PIC is an 18LF2620 at 10MHz.
Brian |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19596
|
|
Posted: Tue Jun 28, 2016 1:37 pm |
|
|
Warnings are just warnings. They can be useful, but also sometimes scary, when not understood. However in this case, it is telling you that you might be wise to think again.
ADDFF, is the routine to add two floating point numbers. Add float to float. Could be just an increment, or addition.
Implies you are using floating point maths in the interrupt. This is basically stupid!....
Floating point maths is slow and bulky. I can't actually think of any good reason to ever use FP maths inside an interrupt, and most of the time, you can avoid it in the PIC code in general.
General rule on interrupts is to do the minimum necessary to handle the interrupt event, and do everything else in the main code.
So think again. Think at least four times about every piece of float arithmetic. Then get rid of it!.... |
|
|
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
Re-entrancy |
Posted: Tue Jun 28, 2016 3:23 pm |
|
|
Yes, thanks. I was updating a float value in the int function. I have now recoded it!
Interesting though that the code worked fine on the v3 compiler.
Can't get rid of fp altogether - data is not always integral!
Thanks
Brian |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19596
|
|
Posted: Tue Jun 28, 2016 11:41 pm |
|
|
It'd do the same on the V3 compiler, it just doesn't display that warning by default.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19596
|
|
Posted: Wed Jun 29, 2016 12:51 am |
|
|
Using integer, doesn't imply that data itself has to be integral.
Use _fixed decimal_. So (for instance) int32, coded in mV, or uV.
The point about 'float' is it supports variable 'ranges' for the data. However few microprocessor jobs actually need this. Most are using voltages over fixed ranges etc.. The downsides of float, are it's low accuracy, large bulk, and huge time overhead.
I did a PID servo algorithm, and used integer maths setup so the low byte was the fractional part. Much faster and smaller than any FP version.
Standard FP only gives you 23bits of working mantissa, yet is slower than 32bit integer. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1912
|
|
Posted: Wed Jun 29, 2016 6:27 am |
|
|
Ttelmah wrote: | ...yet is slower than 32bit integer. |
...By several orders of magnitude. |
|
|
|