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
barryg



Joined: 04 Dec 2006
Posts: 41

View user's profile Send private message

Interrupts disabled during call to prevent re-entrancy...
PostPosted: Wed Oct 17, 2007 1:27 pm     Reply with quote

I have an i2c slave routine that is interrupt-driven. I also have a watchdog running in the application's main loop. If i2c activity ceases for a certain length of time, a watchdog attempts to fix it. First, by putting a character with i2c_write(). If that doesn't free it up, the SSP is disabled and enabled, thus resetting it. That i2c_write(), though, throws a warning--the one in the title of this message.

Now the best way to "fix" this would be to code it in such a way that it doen't risk re-entrancy. If someone knows a good way to do that, I would try it. But, otherwise, I felt I could live with suppressing the warning, for that one statement:
Code:
    #IGNORE_WARNINGS 216
    i2c_write(FEND);              // Soft fix
    #IGNORE_WARNINGS NONE 
That doesn't work. If I comment out the i2c_write() line, the warning goes away, so that is the offending line. As an additional anomaly, the warning is announced as being in the last line of main(), and not here. This suggests that the compiler has deduced this condition, but doesn't remember where it was.

As a final mystery, putting disable_interrupts() around the statement does not prevent the warning, and looking at the .LST file, it's not apparent to me where or how they disable interrupts, as the warning claims.

Anyone have any experience with this?
Ttelmah
Guest







PostPosted: Wed Oct 17, 2007 2:36 pm     Reply with quote

The warning, is just that, _a warning_, not a major problem. All that will happen, is that whenever an I2C_WRITE is used in the main, a disable_interrupt instruction will automatically be inserted in front of it, and an enable_interrupt after it. The code will run fine, _provided this is not happening on some routine that involves a long 'handling' time_. For a single call like this, which is not called at all in the normal cause of events, just ignore the warning.
The code will compile fine with the warning present.
The warning is triggered by the two routines being the same (in the interrupt handler and in the main), and so needs to be ignored for the whole program, and not just the single location shown.

Best Wishes
barryg



Joined: 04 Dec 2006
Posts: 41

View user's profile Send private message

PostPosted: Wed Oct 17, 2007 3:00 pm     Reply with quote

You are right, and the program does work fine. But I would like to be able to produce a "clean" compile. A bit obsessive, perhaps, but being engineers is what got us into this business in the first place Smile

I also found I could supress the warning by inserting the ignore in the last line of main(). That supresses the warning when compiler makes its determination. But, of course it will suppress any warning of that type that may come along.

I thought it was worth asking about, anyway.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Wed Oct 17, 2007 7:35 pm     Reply with quote

If i2c_write is not too long, perhaps you could write a separate version of that function for the ISR and the main program. Since you only call i2c_write from the main program when the ISR activity has timed out, there is no real danger of accessing the serial port hardware from both places at once.

Robert Scott
Ypsilanti, Michigan
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