Example code for banked memory model

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

Example code for banked memory model

ソリューションへジャンプ
4,920件の閲覧回数
ThomasH
Contributor II
Hi,
 
Where can I find example code or documents about programming in banked memory model? How do I have to declare functions,..... I can´t find any examples in the compiler documentation.
 
Thanks!
Thomas
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,786件の閲覧回数
CrasyCat
Specialist III

Hello

Function should be declared as __near function as follows
/* prototype */
void __near Test_Func(void);
 
It should be defined in segment NON_BANKED as follows:
/* function code */
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void Test_Func(void)
{
  ....
  ....
}
#pragma CODE_SEG DEFAULT
 
That should be fine

CrasyCat

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,786件の閲覧回数
CrasyCat
Specialist III

Hello

There is nothing special to do in respect of function definition when you are building in BANKED memory model.

Just rebuild everything with -Mb and the compiler will care about invoking the function with CALL instead of JSR.

Only think you have to really take care of is you HAVE TO place your interrupt function in NON BANKED flash. Entry within the vector table are 16-bit wide. So you need to make sure interrupt functions are placed in NON-BANKED memory.

I am usually recommending to define the interrupt function in the section NON_BANKED as follows:

#ifndef __SMALL__
#pragma CODE_SEG __NEAR_SEG NON_BANKED
#endif
interrupt void INCcount(void) {
    /* Insert Code here */
}
#ifndef __SMALL__
#pragma CODE_SEG DEFAULT
#endif

I hope this helps.

CrasyCat

1,786件の閲覧回数
ThomasH
Contributor II
Hello,
 
Thanks for your answer.
 
For example I have the function Test_Func. How do I have to declare this function that this function will be linked into the non banked section?
 
/* prototype */
void __near Test_Func(void);
 
/* function code */
void __near Test_Func(void)
{
  ....
  ....
}

Is the above declaration right or do I also have to use #pragma?

/* prototype */
void __near Test_Func(void);
 
/* function code */
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void __near Test_Func(void)
{
  ....
  ....
}
#pragma CODE_SEG DEFAULT
 
 
I´m sorry for my (stupid) questions - I´m a newbie in programming CodeWarrior.
 
Many thanks!
Thomas 

 

 


0 件の賞賛
返信
1,787件の閲覧回数
CrasyCat
Specialist III

Hello

Function should be declared as __near function as follows
/* prototype */
void __near Test_Func(void);
 
It should be defined in segment NON_BANKED as follows:
/* function code */
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void Test_Func(void)
{
  ....
  ....
}
#pragma CODE_SEG DEFAULT
 
That should be fine

CrasyCat

0 件の賞賛
返信