vector.c and the definition of the ISR

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

vector.c and the definition of the ISR

Jump to solution
4,403 Views
Yac
Contributor I
Hello,

I wanted to create a timer ISR in my project for MC68HC908QL4. The CodeWarrior created the file vector.c where the entries for ISR addresses can be written. I did it but the program didn't work: the memory area for interrupt vectors hasn't been filled with the given ISRs from vector.c. Then I found that there is another file - project file ("Project.prm") and there can be created a new entry with command VECTOR and name of the ISR function. In this case the program was compiled correctly and memory for interrupt vectors was filled with the address of my ISR.
Then my question is: what is this file "vector.c" for? IMO it is practically unused now, because the compiler doesn't read the ISR vector data from it, but from the project file "Project.prm".

Best regards,
Jacek.
Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,647 Views
CrasyCat
Specialist III

Hello

In that case add _vectab in your .prm file ENTRIES section. This will make sure the vector table is linked to the application.

For sure you will also need to place the section VECTORS_DATA at the appropriate location in the .prm file (at 0xFFDE).

Note that alternatively you can define your vector table as follows:

#if defined(CW08)
#define LIN_VECTF ( void ( *const ) ( ) )
void (* const _vectab[])( ) @0xFFDC =
#endif /* defined(CW08) */

and add _vectab in your .prm file ENTRIES section.

I hope this helps.

CrasyCat

View solution in original post

0 Kudos
Reply
4 Replies
1,647 Views
CompilerGuru
NXP Employee
NXP Employee
There is no magic going on.
How did you create this project, did you use the new project wizard?

First, the vector.c is only generated by Processor Expert, if you did not chose it during the wizard, then there wont be a vector.c.
This file is automatically updated by Processor Expert, so be careful with modifying it.

Second, the
void (* const _vect[])() @0xFFE0 = {
syntax used in this file should cause that the content is automatically linked.

It looks like this does not happen for you, so how does you file look like? Is it maintained by processor export, or do you manually maintain it (after disabling PE, or exclude this file from the regeneration)?
Using the VECTOR command in the prm is just another way of defining the vectors, but be careful, use just one of the two ways, otherwise the linking step fails with a bit a cryptic message about the double definition of the vector areas.

Daniel

And by the way, which version do you use?
0 Kudos
Reply
1,647 Views
Yac
Contributor I
Hello,

I don't use the Processor Expert. The file vector.c came just from one guy and he simply told me that I should use it to set the interrupt vector. There is no such a line: "void (* const _vect[])() @0xFFE0 = {" inside the vector.c file, and additionaly there are the comments that probably allow user to change the content of the file, so maybe this file hasn't been generated by Processor Expert?
The version of CodeWarrior I use, is 5.7.0 Build 1932.
And below is my vector.c file.

Best regards,
Yac.

#define VECTOR_C
/******************************************************************************
*
* Copyright (C) 2003 Motorola, Inc.
* All Rights Reserved
*
* Filename: $RCSfile: vector.c,v $
* Author: $Author: ttz778 $
* Locker: $Locker: $
* State: $State: Exp $
* Revision: $Revision: 1.0 $
*
* Functions: Vectors table for LIN908QL4 Drivers
*
* History: Initial version
*
* Description: Vector table and node's startup for HC08.
* The users can add their own vectors into the table,
* but they should not replace LIN Drivers vectors.
*
******************************************************************************/

extern void SLIC_ISR(); // SLIC Module ISR
extern void TIM_ISR(); // Timer overflow ISR
extern void _Startup(); // CW08 compiler startup routine declaration

/******************************************************************************
INTERRUPT VECTORS TABLE
User is able to add another ISR into this table instead NULL pointer.
******************************************************************************/

#if !defined(NULL)
#define NULL (0)
#endif /* !defined(NULL) */

#undef LIN_VECTF

#if defined(CW08)
#define LIN_VECTF ( void ( *const ) ( ) )
#pragma CONST_SEG VECTORS_DATA /* vectors segment declaration */
void (* const _vectab[])( ) =
#endif /* defined(CW08) */

#if defined(COSMIC08)
#define LIN_VECTF (void *const)
void *const _vectab[] =
#endif /* defined(COSMIC08) */

{
LIN_VECTF NULL, /* 0xFFDE ADC */
LIN_VECTF NULL, /* 0xFFE0 Keyboard */
LIN_VECTF NULL, /* 0xFFE2 Reserved */
LIN_VECTF NULL, /* 0xFFE4 Reserved */
LIN_VECTF NULL, /* 0xFFE6 Reserved */
LIN_VECTF NULL, /* 0xFFE8 Reserved */
LIN_VECTF SLIC_ISR, /* 0xFFEA SLIC */
LIN_VECTF NULL, /* 0xFFEC Reserved */
LIN_VECTF NULL, /* 0xFFEE Reserved */
LIN_VECTF NULL, /* 0xFFF0 Reserved */
LIN_VECTF NULL, /* 0xFFF2 TIMER overflow */
LIN_VECTF TIM_ISR, /* 0xFFF4 TIMER channel 1 */
LIN_VECTF NULL, /* 0xFFF6 TIMER channel 0 */
LIN_VECTF NULL, /* 0xFFF8 Reserved */
LIN_VECTF NULL, /* 0xFFFA IRQ */
LIN_VECTF NULL, /* 0xFFFC SWI */
LIN_VECTF _Startup /* 0xFFFE RESET */
};

#if defined(CW08)
#pragma CONST_SEG DEFAULT
#endif /* defined(CW08) */
0 Kudos
Reply
1,648 Views
CrasyCat
Specialist III

Hello

In that case add _vectab in your .prm file ENTRIES section. This will make sure the vector table is linked to the application.

For sure you will also need to place the section VECTORS_DATA at the appropriate location in the .prm file (at 0xFFDE).

Note that alternatively you can define your vector table as follows:

#if defined(CW08)
#define LIN_VECTF ( void ( *const ) ( ) )
void (* const _vectab[])( ) @0xFFDC =
#endif /* defined(CW08) */

and add _vectab in your .prm file ENTRIES section.

I hope this helps.

CrasyCat

0 Kudos
Reply
1,647 Views
CrasyCat
Specialist III

Hello

Are you using ProcessorExpert to generate code?
Did you modify the .prm file created by ProcessorExpert?

As far as i know you get a file vector.c only if you let ProcessorExpert generate code for you. In that case I would also let Processor Expert generate the linker file for you.


If you have defined and initialized your vector table ad a constant table of function pointer, you have to tell the linker you want to link it to the application, even though it is not used within the application.

This is done specifying the vector table name within the PRM file ENTRIES block.

CrasyCat

0 Kudos
Reply