Fixup overflow

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

Fixup overflow

Jump to solution
2,374 Views
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.

Labels (1)
0 Kudos
1 Solution
969 Views
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

 

View solution in original post

0 Kudos
3 Replies
970 Views
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 Kudos
969 Views
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 Kudos
969 Views
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 Kudos