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

isr relocate

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







isr relocate
PostPosted: Wed Oct 19, 2005 8:06 am     Reply with quote

I have relocated the interrupt vectors to make my bootloader work. The routine below is located on adderss 0x08 but if I don't make a call to it in my program the compiler removes the function (some kind of opimization maybe). I have looked through the manual but can't find a directive to make the code "stick" withut some extra call

Code:

#org 0x08, 0x24
void isr_relocate(void)
{
#asm
   // Address 0x0008 is the hardware High priority interrupt
   TSTFSZ BootloaderActive            // if bootloader active
   goto LOADER_ISR_ADDR               // then jump to bootloader ISR
   goto APP_BEGIN + 0x08            // jump to application ISR

   nop
   nop
   nop

   // Address 0x0018 is the hardware Low priority interrupt
   TSTFSZ BootloaderActive            // if bootloader active
   goto LOADER_ISR_ADDR + 0x10      // then jump to bootloader ISR
   goto APP_BEGIN + 0x18            // jump to application ISR
#endasm
}

// Some other place in the code (this is what I want to avoid)
...
  if(some_variable_that_never_will_be_true)
    isr_relocate();
...



Thanks
Martin[/code]
asmallri



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

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

PostPosted: Wed Oct 19, 2005 10:24 am     Reply with quote

Here is some early code I used when I was migrating from assembler to CCS C and need to retian my assembler interrupt hanlders because I used multiple high priority interrupts on the PIC18F which were not supported by CCS at the time.

I fooled the compiler into thinking the interrupt vectors were located elsewhere then I put the real vectors in place. The compiler did not optimise out this code.


Code:

// prevent the compiler sticking code between 0x0004 and 0x0007
#build(reset=0x00:0x07)


// fool the compiler to allow access to the real high and low priority vectors
#build(interrupt=0x028)
#org 0x0020, 0x002f {}

   /* Map the high priority interrupt vector */
#org 0x0008, 0x000f
void my_hp_intr (void)
   {
   #asm
   goto   0x0100
   #endasm
   }

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



#org 0x0100, 0x01ff
void HPIntrHdlr(void) {
   #asm ASIS

....

_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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