CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Re-entrancy warning

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

Re-entrancy warning
PostPosted: Tue Jun 28, 2016 12:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 28, 2016 1:33 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=42118&highlight=addff
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Tue Jun 28, 2016 1:37 pm     Reply with quote

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

View user's profile Send private message

Re-entrancy
PostPosted: Tue Jun 28, 2016 3:23 pm     Reply with quote

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: 19467

View user's profile Send private message

PostPosted: Tue Jun 28, 2016 11:41 pm     Reply with quote

It'd do the same on the V3 compiler, it just doesn't display that warning by default....
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Wed Jun 29, 2016 12:51 am     Reply with quote

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: 1907

View user's profile Send private message

PostPosted: Wed Jun 29, 2016 6:27 am     Reply with quote

Ttelmah wrote:
...yet is slower than 32bit integer.


...By several orders of magnitude.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group