Defining a functions location in ROM

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

Defining a functions location in ROM

Jump to solution
2,692 Views
hard_wired
Contributor I
I have the need to place an interrupt's function body at a predefined address in ROM.
 
How would I go about doing this in C?
 
- Mike
Labels (1)
Tags (1)
0 Kudos
1 Solution
879 Views
CrasyCat
Specialist III
Hello
 
Just to close the loop here.
 
I agree with CompilerGuru. @ operator is not applicable to functions.
So you have to place the function in a specific section.
 
The section NON_BANKED is used is standard project to place code which needs to be allocated in the non-paged ROM area.
And you need to write the pragma as
#pragma CODE_SEG __NEAR_SEG NON_BANKED
 
I hope this helps.
 
CrasyCat

View solution in original post

0 Kudos
3 Replies
879 Views
Nabla69
Contributor V
Hello,

Have you tried like for variables ?
void function(void) @ 0x4500; // prototype

or

#PRAGMA CODE_SEG SPECROM
void function(void); // prototype
#PRAGMA CODE_SEG DEFAULT
(...)

#PRAGMA CODE_SEG SPECROM
void function(void) {
blabla;
}
#PRAGMA CODE_SEG DEFAULT

with SPECROM declared in your PRM file.

Alfreda
879 Views
CompilerGuru
NXP Employee
NXP Employee
The @ syntax is not supported for functions as far as I know,
but the #pragma CODE_SEG should work.
For a HC12/S12/S12X (not sure about the CPU of the OP), its usually enough to place interrupt handlers anywhere in a non paged region. For this there is already an existing section (I think its called NON_PAGED. but I'm not sure). Also I would add a __NEAR_SEG qualifier for the HC12 to the #prama.

Daniel

880 Views
CrasyCat
Specialist III
Hello
 
Just to close the loop here.
 
I agree with CompilerGuru. @ operator is not applicable to functions.
So you have to place the function in a specific section.
 
The section NON_BANKED is used is standard project to place code which needs to be allocated in the non-paged ROM area.
And you need to write the pragma as
#pragma CODE_SEG __NEAR_SEG NON_BANKED
 
I hope this helps.
 
CrasyCat
0 Kudos