ARM Technical Support Knowledge Articles

SHARE INTERRUPT VECTOR WITH BOOT LOADER

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

I have implemented a bootloader that contains an interrupt handler for the vector address 0x20. However, the downloaded application also needs an interrupt service routine for the vector address 0x20. How can I share interrupt vectors so that I have a separate interrupt function in the bootloader and in the downloaded application?

ANSWER

The following assembler program allows you to redirect an interrupt vector. When the bit boot is set, the interrupt function irq (which is part of your boot loader) is executed. When boot is clear, the interrupt vector is redirected to 0x20020. All other interrupt vectors are redirected to a vector table at address 0x20000.

$segmented
$case   ; case sensitive symbols

VEC_SEG  EQU 2
VEC_OFF  EQU 0H

; The RESET vector is used by the boot application
VECT_TAB SECTION CODE AT 4
VEC_PROC PROC
  JMPS VEC_SEG,VEC_OFF+004H
  JMPS VEC_SEG,VEC_OFF+008H
  JMPS VEC_SEG,VEC_OFF+00CH
  JMPS VEC_SEG,VEC_OFF+010H
  JMPS VEC_SEG,VEC_OFF+014H
  JMPS VEC_SEG,VEC_OFF+018H
  JMPS VEC_SEG,VEC_OFF+01CH
  JMP  irq8                                      ; irq8
  JMPS VEC_SEG,VEC_OFF+024H
  JMPS VEC_SEG,VEC_OFF+028H
  JMPS VEC_SEG,VEC_OFF+02CH
  :
  :
VEC_PROC ENDP
VECT_TAB ENDS

extrn boot:bit
extrn irq:near

?PR?irq8 section code
irq8 proc near
  JB   boot,irq8_boot
  JMPS VEC_SEG,VEC_OFF+20H
irq8_boot:
  JMP  irq
irq8 endp
?PR?irq8 ends

  end

The bootloader may be implemented in C. Here is an example:

void irq (void) interrupt irq=CACHED  {
   ;                          // code of your interrupt function
}

bit boot;

void bootloader ()  {
  ;
}

void main (void)  {
  boot = 1;                       // use local irq in bootloader
  bootloader ();

  boot = 0;                       // use irq function in user app
  ((void (far *) (void)) 0x200000) ();  // start user app

  while (1);
}

Note: You need to use the C166 Compiler Version 5.04 since it allows using the CACHED attribute even for non XC16x targets. The CACHED attribute disables the generation of an interrupt vector which is supplied in this example by an assembler module.

You may download a complete application example from the attachment to this Knowledgebase Article.

SEE ALSO

Article last edited on: 2007-01-18 10:02:50

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential