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

PIC18F6520 "Fast" Fast interrupt

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







PIC18F6520 "Fast" Fast interrupt
PostPosted: Wed Oct 20, 2004 7:19 am     Reply with quote

Folk,
I have been writing code using CCS 3.207 and was wondering if there was a way to reduce the interrupt latency of the external interrupt.
My interrupt routine is a trivial response to an external trigger, (clear a variable, clear timer1).
The code is short enough to actually fit in the memory at 0x0008-0x0018 although the compiler insists on locating it elsewhere and jumping there.
Is there any way I can encourage the compiler to squeze my ISR into this gap?
Org 0x0008, 0x0018 is apparently not a valid range.

On a related note, is there any method of optimizing out the majority of the completely unnecessary context saving that the compiler uses on a normal interrupt? (Other than a global interrupt handler)

Thanks for any assistance,

Richard, UK
Guest








PostPosted: Wed Oct 20, 2004 7:47 am     Reply with quote

Quote:
Is there any way I can encourage the compiler to squeze my ISR into this gap?
Org 0x0008, 0x0018 is apparently not a valid range.


Yes. You can fool the compiler into thinking the vectors will be elsewhere and then you have control of the original vectors

Code:
#build(interrupt=0x028)
#org 0x0020, 0x002f {}


   /* Map the high priority interrupt vector */
#org 0x0008, 0x000f
void my_hp_intr (void)
   {
   #asm ASIS
   // ... do your stuff here
   retfie   1   //; fast return from interrupt
   #endasm
   }


   /* Map the low priority interrupt vector */
#org 0x0018, 0x001f
void my_lp_intr (void)
   {
   #asm
   goto   0x0200
   #endasm
   }



#org 0x0200, 0x5fff // or wherever
void LPIntrHdlr(void) {
// etc etc etc
Richard
Guest







Faster interrupt
PostPosted: Wed Oct 20, 2004 9:11 am     Reply with quote

Thanks for your suggestion I carried out the following:
Code:

#org 0x0008, 0x0014

void Fake_ISR() {
// This is really the fast interrupt
// External interrupt

   #asm
      CLRF   0xFCF  // clear Timer1H
      CLRF   0xFCE  // clear Timer1L
      CLRF   0x39   // clear CounterH
      CLRF   0x38   // clear CounterL
      BCF    0xFF2.1   //clear interrupt flag
      RETFIE 1
   #endasm

}
#org default

This carried out the ISR as expected. I also need to map my Counter variable so that it doesn't move about if I change my variables ;-)

This produced the following list snipppet

Code:

org 0x0008, 0x0014 
....................   
.................... void Fake_ISR() { 
.................... // This is really the fast interrupt 
.................... // External interrupt 
....................   
....................    #asm 
....................       CLRF   0xFCF  // clear CounterH 
*
0008:  CLRF   FCF
....................       CLRF   0xFCE  // clear CounterL 
000A:  CLRF   FCE
....................       CLRF   0x39   // clear CounterH 
000C:  CLRF   39
....................       CLRF   0x38   // clear CounterL 
000E:  CLRF   38
....................       BCF    0xFF2.1   //clear interrupt flag 
0010:  BCF    FF2.1
....................       RETFIE 1 
0012:  RETFIE 1
....................    #endasm 
....................   
.................... } 
0014:  RETLW  00
.................... #org default 


ie It did exactly what was wanted (except for the spare RETLW 00 from the closing brace of the void function, which never gets called).

My original mistake was to try and #ORG the CCS #int_ext ISR.

Thanks for your help!

Richard
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 20, 2004 10:49 am     Reply with quote

No problem.

Don't forget you can use your C labels in assembler

Code:

byte   CounterH;  #locate   Rx_HeadL = 0x40
byte   CounterL;  #locate   Rx_HeadL = 0x41


then your code becomes..

Code:
#org 0x0008, 0x0014

void Fake_ISR() {
// This is really the fast interrupt
// External interrupt

   #asm
      CLRF   0xFCF        // clear Timer1H
      CLRF   0xFCE        // clear Timer1L
      CLRF   CounterH   // clear CounterH
      CLRF   CounterL   // clear CounterL
      BCF    0xFF2.1      //clear interrupt flag
      RETFIE 1
   #endasm



Remember to keep you variables below 0x80 to save having to use the BSR
[/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