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

Interrupt handling?

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








Interrupt handling?
PostPosted: Fri Oct 24, 2008 8:36 am     Reply with quote

Hi

In my code I disabled ext_x interrupt but poll for it.

My Q is what way does the pic / ccs handle this ?

The pic will goto addr: 0008 and execute the ccs dispatcher code but the ccs code is real long.

Code:
0008:  MOVWF  05
000A:  MOVFF  STATUS,06
000E:  MOVFF  BSR,07
0012:  MOVLB  0
0014:  MOVFF  FSR0L,0D
0018:  MOVFF  FSR0H,08
001C:  MOVFF  FSR1L,09
0020:  MOVFF  FSR1H,0A
0024:  MOVFF  FSR2L,0B
0028:  MOVFF  FSR2H,0C
002C:  MOVFF  PRODL,14
0030:  MOVFF  PRODH,15
0034:  MOVFF  PCLATH,16
0038:  MOVFF  00,0F
003C:  MOVFF  01,10
0040:  MOVFF  02,11
0044:  MOVFF  03,12
0048:  MOVFF  04,13
004C:  BTFSS  INTCON.INT0IE
004E:  GOTO   0058
0052:  BTFSC  INTCON.INT0IF
0054:  GOTO   00AA
0058:  BTFSS  INTCON3.INT1IE
005A:  GOTO   0064
005E:  BTFSC  INTCON3.INT1IF
0060:  GOTO   00B2
0064:  MOVFF  0F,00
0068:  MOVFF  10,01
006C:  MOVFF  11,02
0070:  MOVFF  12,03
0074:  MOVFF  13,04
0078:  BSF    0E.7
007A:  MOVFF  0D,FSR0L
007E:  MOVFF  08,FSR0H
0082:  MOVFF  09,FSR1L
0086:  MOVFF  0A,FSR1H
008A:  MOVFF  0B,FSR2L
008E:  MOVFF  0C,FSR2H
0092:  MOVFF  14,PRODL
0096:  MOVFF  15,PRODH
009A:  MOVFF  16,PCLATH
009E:  MOVF   05,W
00A0:  MOVFF  07,BSR
00A4:  MOVFF  06,STATUS
00A8:  RETFIE 0


Code:

.................... #INT_EXT
.................... void ext0(void){int a; a=0;}
00AA:  CLRF   a
.................... 
00AC:  BCF    INTCON.INT0IF
00AE:  GOTO   0064



I ask because I wrote some code that must be real fast and therefore must poll in a loop for the EXTxIF, but will the pic will go to addr 0008 and execute the code???

Some hints.
Ttelmah
Guest







PostPosted: Fri Oct 24, 2008 9:07 am     Reply with quote

Nothing to do with the compiler...
This is down to how the _chip_ handles interrupts.
The code really doesn't 'come into it'.

There are three flag bits associated with each interrupt:

First, the 'flag'. This is set by the hardware event. The event on some interrupts may be changed (so on the level interrupts for example, you may change whether this is set by a rising or falling edge).

Then the individual 'enable'. This is controlled by the enable/disable interrupt call.

Then the 'global' enable (set by the same calls, but using #INT_GLOBAL).

The interrupt handler (at address 8), is _only_ called, when all three bits are set.

You have turned off the 'enable', so the handler will not be called.

Clearing the interrupt will become your responsibility (the compiler will automatically clear interrupts when the 'handler' routine is called).
Also remember that for some interrupts (serial data received, RB change etc.), the event causing the interrupt itself, _must_ be cleared before the interrupt can be cleared.

For the '18' chips, there is also another bit involved, the hardware 'priority' flag. This has it's own caveats.

Remember, that though testing the flag bit is a great idea to remove the latency implicit in calling the handler, if you have other interrupt sources enabled, and a chage occurs while the code is in the handler for these, you will not return to the 'main' routine, till this handler has completed, potentially 're-introducing' latency problems.

Best Wishes
Guest








PostPosted: Sat Oct 25, 2008 2:38 am     Reply with quote

Hi

Sorry for the late response.

In this ex will addr 0008 NOT be entered because the INT0IE=0. ?

Code:
INT0IE=0;//dis int
INT0IF=0;//clear pending int
while (!INT0IF);//wait for int
...more code...
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