Defining a functions location in ROM

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Defining a functions location in ROM

跳至解决方案
3,819 次查看
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,006 次查看
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,006 次查看
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,006 次查看
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,007 次查看
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 项奖励
回复