Defining a functions location in ROM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Defining a functions location in ROM

ソリューションへジャンプ
3,815件の閲覧回数
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
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
2,002件の閲覧回数
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 件の賞賛
返信
3 返答(返信)
2,002件の閲覧回数
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
2,002件の閲覧回数
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

2,003件の閲覧回数
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 件の賞賛
返信