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

Interrupts disabled during call to prevent re-entrancy

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



Joined: 05 Jul 2006
Posts: 15

View user's profile Send private message

Interrupts disabled during call to prevent re-entrancy
PostPosted: Thu Aug 10, 2006 5:57 am     Reply with quote

Hi, I have an I2C_read() and I2C_write command in the timer interrupt, the compiler show some warning as:

>>> Warning 216 : Interrupts disabled during call to prevent re-entrancy: @I2C_WRITEU_1_59_60_20000000

>>> Warning 216 : Interrupts disabled during call to prevent re-entrancy: @I2C_READU_1_59_60_20000000

how can I eliminate these warning?
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

View user's profile Send private message Visit poster's website

PostPosted: Thu Aug 10, 2006 6:25 am     Reply with quote

Set a global flag in the timer interrupt and do the main work in the main while() loop (based on the status of the flag). when you have completed the work, i.e. read and write to an I2C device, reset the flag.

In some cases, you may need to disable the interrupt during the work operation.

As a rule, do as little as possible in an interrupt handler.
_________________
Regards,
Simon.


Last edited by sjbaxter on Thu Aug 10, 2006 6:27 am; edited 1 time in total
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

PostPosted: Thu Aug 10, 2006 6:25 am     Reply with quote

You should never make calls like read/write of peripherals from within an interrupt routine. Create a flag that is set by the interrupt and test for it in main, so you can do your I2C read/write from main.

This assumes that your main loop runs fast and is not impeded by calls to delays or sits waiting for an event to complete. My main loop *only* polls around checking event flags and goes off and services a task when the flag becomes true.

hope this helps.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 10, 2006 6:36 am     Reply with quote

From the FAQ
_________________
I came, I saw, I compiled.
JaSoN



Joined: 05 Jul 2006
Posts: 15

View user's profile Send private message

PostPosted: Thu Aug 10, 2006 7:45 am     Reply with quote

Thanks, the warning is solved..

I want to ask if I want to program a function in timer interrupt, when a SSP interrupt comes, will the timer interrupt be disabled?
grasspuddle



Joined: 15 Jun 2006
Posts: 66

View user's profile Send private message

PostPosted: Thu Aug 10, 2006 10:28 am     Reply with quote

when you enter an interrupt, interrupts are automatically disabled

unless you have a high priority interrupt get called when a low priority interrupt is running
Ttelmah
Guest







PostPosted: Thu Aug 10, 2006 12:02 pm     Reply with quote

It depends to an extent what you mean.
The interrupt _flag_ will still be set, but the response to this flag, will not occur, till you exit the first interrupt.

Best Wishes
Guest








PostPosted: Sat Jan 26, 2008 4:32 pm     Reply with quote

It seems that the compiler doesn't distinguish between high and low priority interrupts when "disabling interrupts to prevent re-entrancy". If I have a complex low-priority interrupt that is a possible source of re-entrancy, shouldn't I be able to have a high priority interrupt interrupt it? Seems like there ought to be a way to include only low-priority interrupts in the re-entrancy calculation...
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