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 - just when do they interrupt ?

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







Interrupts - just when do they interrupt ?
PostPosted: Fri Nov 01, 2002 1:05 pm     Reply with quote

Hi all,

When we say "interrupt" - just how "interrupting" is an interrupt ?.

For example, if you were half way through writing to EEprom and an interrupt occured, say the rda. Does the PIC finish writing to eeprom before it executes the interrupt or does it actually cease writing to eeprom, do the interrupt and then resume with the eeprom write ?

Obviously the PIC could be doing anything not just writing to eeprom. It could be sending an RS232 string or it could be executing a delay_ms(x).
Actually thats another interesting one - what happens in the case of a delay_ms ?

As ever,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 8395
johnpcunningham
Guest







Re: Interrupts - just when do they interrupt ?
PostPosted: Fri Nov 01, 2002 1:31 pm     Reply with quote

<font face="Courier New" size=-1></font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8398
johnpcunningham
Guest







Re: Interrupts - just when do they interrupt ?
PostPosted: Fri Nov 01, 2002 1:36 pm     Reply with quote

<font face="Courier New" size=-1>A lot of this is discussed in the CCS manual and the data sheets.

You are right, the processor could be doing anything when an interrupt occurs. Generally, the processor finishes the assembly command and services the interrupt by jumping to the interrupt vector. Once the RETFIE command is run (assuming no other interrupts, the processor returns to the "next" line of code that it had left. example:

movlw 0x55;
movwf 0x06;
movlw 0x66;
movwf 0x06;

If an interrupt occured while "movlw 0x55" was being executed, that line would finish, the interrupt vector would be called and run, then the processor would come back (after the RETFIE) and run "movwf 0x06;" and continue.
-------------------------------------------
It is up to you, the designer, to determine when interrupts should be enabled or disabled and other sensitive timings that must be met.

1) DELAY_MS or other
An interupt will leave the delay routine, service the interupt, and then come back pick up where it left off. This will add some "delay" to your delay routine and is as long as the interrupt service runs

2) UARTs, EEPROM, other...
It is up to the user to turn on or off interrupts prior to running a certain function. If you are doing something that is timing specific (i.e. software UARTs), you may want to dis-able the interrupt before entering the routine. Once, completed, you can re-enable the interrupt.

If you disabled a specific interrupt, the interrupt FLAG(s) will be still be set for that interrupt if one occurs. The difference is that the processing control will not leave the current routine...the flags simply gets set (as long as the interrupt is not enabled). A good idea would be like:

-- disable a specific interrupt
-- go do a specific funciton or funciton call
-- return and re-enable interrupt (flags may be set if an interrupt condition occured when in the specific funciton call

For example, you can disable the TIMER1 interrupt but if it overflows, the interrupt flag will get set regardless. The flag being set does not cause an interrupt "unless" the Interrupt is enabled for TIMER1. If the flag is set and the Interrupt is enabled, the processor will immediately interrupt and run the int service routine for TIMER 1.

On the 16F877, see section 12.10 of the datasheet for information on interrupts, timing, and latency

JC
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8399
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