ISR Vector Outside of 16k page

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ISR Vector Outside of 16k page

Jump to solution
1,138 Views
9S12_Raj
Contributor I

Hello,

 

I was wondering if there is a way to complie a project that has its ISR vector in paged memory?

Labels (1)
Tags (1)
0 Kudos
1 Solution
865 Views
kef
Specialist I
  • So is it possible to have a bootloader that can jump to 2 different application?

     

Of course it's possible.

1) in case applications are small enough to fit 16k page, you need to edit prm of application to make apps compiled to addresses 0x8000-0xBFFF. Application vectors also should be placed into the same page window (probably at the top of page). Then in bootloader you make all vectors, except reset vector, pointing to application vectors in page window. (Of course, if bootloader is  interrupt driven - you need some way to redirect interrupt vectors from bootloader to application. ) Operation is simple, you switch PPAGE in bootloader to specific application and jump to app.

 

2) In the case applications are big or paged, PPAGE trick won't work and you need download to MCU some table of vectors table, in which each table of vectors points to ISRs of specific application. Bootloader then would need to redirect interrupts to specific table of vectors.

 

View solution in original post

0 Kudos
12 Replies
865 Views
kef
Specialist I

Vectors are 16bits wide pointers and can point only to nonbanked memory. If you have a lack of nonbanked memory, then you may call big banked routines from small nonbanked ISR's.

0 Kudos
865 Views
9S12_Raj
Contributor I

So is it possible to have a bootloader that can jump to 2 different application?

 

If so can you give me an idea of how.

 

Thank you,

0 Kudos
866 Views
kef
Specialist I
  • So is it possible to have a bootloader that can jump to 2 different application?

     

Of course it's possible.

1) in case applications are small enough to fit 16k page, you need to edit prm of application to make apps compiled to addresses 0x8000-0xBFFF. Application vectors also should be placed into the same page window (probably at the top of page). Then in bootloader you make all vectors, except reset vector, pointing to application vectors in page window. (Of course, if bootloader is  interrupt driven - you need some way to redirect interrupt vectors from bootloader to application. ) Operation is simple, you switch PPAGE in bootloader to specific application and jump to app.

 

2) In the case applications are big or paged, PPAGE trick won't work and you need download to MCU some table of vectors table, in which each table of vectors points to ISRs of specific application. Bootloader then would need to redirect interrupts to specific table of vectors.

 

0 Kudos
865 Views
9S12_Raj
Contributor I

My situation is the 2nd one.  My application is big and will probably take several pages.  Can you give me an example of the redirected interrupts.  I am planning to use Memory Banker.

 

Thank you,

0 Kudos
865 Views
kef
Specialist I

You didn't tell what MCU your are using. On S12X vectors redirection is simple. For this purpose you have interrupt vector base register. That register is 8bits wide and contains upper half of interrupt vectors address. IVBR contains 0xFF by default on reset, which means that all vectors are at 0xFFxx. So one application could have vectors say at 0xEFxx, another one at 0x5Fxx. Bootloader then should set up IVBR and jump to where application's vector is pointing to.

 

S12 have no IVBR register and each bootlaoder's ISR should jump to application's ISR. Certainly you need some variable in bootloader code, that will help determining where are application's vectors. Please note, that loadable applications should have reserved space for this variable, so that it is never overwritten by application. Bootloader ISR's could look like this:

 

unsigned short ivbr; //

 

#pragma TRAP_PROC

void irq_isr(void)

{

   asm {

      LDD  ivbr

      JMP   [D, Virq]

   }

}

 

In this case ivbr should be 0 for normal reset vectors at 0xFFxx. For vectors at 0xEFxx (reset vector at 0xEFFE) ivbr should contain 0xF000 (0xEFFE+2).

 

 

0 Kudos
865 Views
9S12_Raj
Contributor I

I was curious where I can get a list of all your compiler pre-processor keywords and startup syntax for CW when using the 9S12XEP100.

 

Thank you

0 Kudos
865 Views
CrasyCat
Specialist III

Hello

 

> I was curious where I can get a list of all your compiler pre-processor keywords and

> startup syntax for CW when using the 9S12XEP100

 

I assume you are looking for a list of predefined macros in the Freescale HC12 compiler. Am I right?

They are listed in the {Install}\help\PDF\Compiler_HC12.pdf manual in chapter Using the Compiler, section Compiler Predefined Macros.

 

Here I assume you are using CodeWarrior for HC12 V5.1.

 

I do not understand what you mean with "startup syntax ". Can you be more specific please?

 

CrasyCat

0 Kudos
865 Views
9S12_Raj
Contributor I

Hello CrasyCat,

 

"startup syntax" refers to keywords and syntax of the Start12.c and prm files. 

 

Thanks for the Compiler_HC12.pdf I will review it.

0 Kudos
865 Views
CrasyCat
Specialist III

Hello

 

You can find information on prm file syntax in  {Install}\help\PDF\Build_Tools_Utilities.pdf section Smart Linker.

 

The start12.c module is written in High-level Inline Assembler. You can find information on this syntax in

{Install}\help\PDF\Compiler_HC12.pdf manual in chapter Using the Compiler, section High-Level Inline Assembler for Freescale HC(S)12.

 

CrasyCat

0 Kudos
865 Views
9S12_Raj
Contributor I

Oh the controller I am using is the 9S12XEP100.

 

So if I understand you then the ivbr should contain 0xF000 if the relocated ISR vector is in the 0xFF page or from 0xC000 higher.  Does this also mean that when the relocated vector is in lower memory the ivbr should contain 0x4000?

 

I am trying to get 2 relocation table setup (one for each app) so I am just looking for an example of how to do that in "C" if possible.

 

Also what should bootloader do for unused ISR's that the app might need.

 

Thank you very much for your support.

0 Kudos
865 Views
kef
Specialist I

On S12X you have IVBR register and all it is quite simple. IVBR is 8bits wide, and contains upper half of vectors address. You may remap (move) whole vectors table from 0xFFxx to any other 16bit address. On reset IVBR is 0xFF and all vectors are at 0xFFxx. You write 0x40 to IVBR to move whole vectors table to 0x40xx.

 

You don't need any assembly to remap vectors on S12X(E).

0 Kudos
865 Views
9S12_Raj
Contributor I

curious if the there can be conditional flags in the prm file?

0 Kudos