Fixup overflow

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

Fixup overflow

跳至解决方案
2,405 次查看
sandeepnaik
Contributor I

I am using MC9S08LG32 controller and developing software using CW 10.2 Special Edition: Code Warrior for Micro-controllers 10.2 (Eclipse, Windows hosted). I am using small memory model (where by default far locations are used)

I am getting Fix-up Overflow in one of my interrupt service routine.

In that routine is a variable say count.

When I explicitly specify this variable as near I get the fix-up overflow error. As soon I remove this near specifier the error is solved. Can some-one tell me what exactly is happening.

标签 (1)
0 项奖励
1 解答
1,000 次查看
bigmac
Specialist III

Hello,

 

If your requirement is that the count variable retain its value between function calls, the static modifier should be used.  The variable will then be placed in RAM, rather than the stack.  Unlike global variables, the variable will only be visible from within the function in which it is defined.

 

Regards,

Mac

 

在原帖中查看解决方案

0 项奖励
3 回复数
1,001 次查看
bigmac
Specialist III

Hello,

 

If your requirement is that the count variable retain its value between function calls, the static modifier should be used.  The variable will then be placed in RAM, rather than the stack.  Unlike global variables, the variable will only be visible from within the function in which it is defined.

 

Regards,

Mac

 

0 项奖励
1,000 次查看
CrasyCat
Specialist III

Hello

 

  When you define a variable inside of a function, the variable is allocated on the stack.

 

  The near qualifier only applies to variables allocated between 0x00 and 0xFF.

   As your stack is not allocated there, you should not define your local variable a near.

 

CrasyCat

0 项奖励
1,000 次查看
sandeepnaik
Contributor I

When you define a variable inside of a function, the variable is allocated on the stack.

 

  The near qualifier only applies to variables allocated between 0x00 and 0xFF.

   As your stack is not allocated there, you should not define your local variable a near.

 

CrasyCat

 

Sir,

The variable count I declared is a global variable and is not allocated space in the routine.

 

0 项奖励