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 CCS Technical Support

Help interrupts in pic16f877a

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



Joined: 16 Jul 2013
Posts: 3
Location: vietnam

View user's profile Send private message

Help interrupts in pic16f877a
PostPosted: Mon Mar 31, 2014 10:07 am     Reply with quote

I have read datasheet of pic16f877a.They say global interrupt bit is automatically blocked(GIE=0) when have interupts occur.but I noticed that when people write programs,the first thing is disable_interrupts(global) and after implement ISR then enable_interupts(global).It have automatically blocked.Can you explain to me please?
_________________
anhyeuem
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Mar 31, 2014 11:05 am     Reply with quote

They don't.....

Look at the example files. None of the ISR's ever calls 'enable_interrupts(GLOBAL)'.

Search here, and you will find the (thankfully) few people doing this, being told quite forcibly _not_ to do it. It is lethal (to the program). The 'disable' won't cause any problem (since the interrupt is already disabled when you enter the ISR code), but 'enable_interrupt(GLOBAL)', inside an ISR, can result in the ISR being called again inside itself, and will then crash the code.
The key point is that the return instruction used in an ISR (RETFIE) enables the global interrupt _after_ it executes, ensuring the code has left the ISR before the interrupts are re-enabled....
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