Using CW to build vector tables for the HCS12x, Linker Error L1108

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

Using CW to build vector tables for the HCS12x, Linker Error L1108

Jump to solution
2,832 Views
Eggman
Contributor I
Hello-
 
I am using CW to create a program in C for the 9S12XDP512.  This program uses interrupts, but I have not been able to figure out how to build the vector table.  I have searched this website but not found any documentation that explains the compliation process for this particular microcontroller.  The closest I have come is document AN2216/D but that covers a different chip.  I have been trying to use the information provided there since I expect them to be similar, but nothing has worked.
 
Building an interrupt routine should consist of two parts: getting the ISR located at a known memory address and then getting this address loaded into the vector table position for the interrupt it is handling.  To do this I have this code:
 
// inside main.c
#pragma CODE_SEG __NEAR_SEG ROM_C000
#pragma TRAP_PROC
void ISR(void) { /* interesting code here */ }
#pragma CODE_SEG DEFAULT
 
// inside the PRM file
SEGMENTS
    ROM_C000 = READ_ONLY 0xC000 TO 0xFEFF
    /* other defined segments */
END
...
VECTOR 0 _Startup // provided by the project wizard tool
VECTOR 'n' ISR 
 
There is a formula to calculate 'n' in order to get the correct entry in the vector table.  However, ANY value I have tried so far produces the following error during the linking stage:
 
Link Error   : L1108: Initializing of Vector ISR failed because of over- or underflow of vector value
Link Error   : Link failed
I get this error whether I use the true value that I calculate from the formula or even something small like 2.  What is the real way to get your vector table built?  I cannot tell if this error is produced by trying to use a value that genuinely falls outside the range of entries in the vector table, or if I stored the function at a memory address that is too large to store as an entry in the table.  Since the function is in non-paged memory I don't see how the latter would be true.
Labels (1)
Tags (1)
0 Kudos
1 Solution
491 Views
CompilerGuru
NXP Employee
NXP Employee
The problem is that the section name ROM_C000 has to be defined in the PLACEMENT, not in the SEGMENTS.
SEGMENTS
...
    ROM_C000_AREA = READ_ONLY 0xC000 TO 0xFEFF
...
END
PLACEMENT
...
    ROM_C000 INTO ROM_C000_AREA;
...
END


One good thing to check for such cases is the map file. It it created even if the linking fails with all the information available at the time of the failure.

About the 'n' calculation. If you prefer, you can also specify the vector address instead of the vector number.

VECTOR ADDRESS 0xFFFE _Startup
is just the same as
VECTOR 0 _Startup

Daniel

View solution in original post

0 Kudos
3 Replies
491 Views
mEnO181
Contributor I
hii all,
i've a problem,i've just started using the CW, i'm using CW4.5 and  i can't find vector_table.c, i need some help cause i can't figure out this process, i'm working on MC9S12XEP100.
thank you
0 Kudos
492 Views
CompilerGuru
NXP Employee
NXP Employee
The problem is that the section name ROM_C000 has to be defined in the PLACEMENT, not in the SEGMENTS.
SEGMENTS
...
    ROM_C000_AREA = READ_ONLY 0xC000 TO 0xFEFF
...
END
PLACEMENT
...
    ROM_C000 INTO ROM_C000_AREA;
...
END


One good thing to check for such cases is the map file. It it created even if the linking fails with all the information available at the time of the failure.

About the 'n' calculation. If you prefer, you can also specify the vector address instead of the vector number.

VECTOR ADDRESS 0xFFFE _Startup
is just the same as
VECTOR 0 _Startup

Daniel
0 Kudos
491 Views
Eggman
Contributor I
Thank you, that did the trick!
0 Kudos