View Full Version : Programming problem

04-03-2008, 07:28 PM
Hey while I am compiling I am getting this error what does this mean

"global variable out of SRAM".

04-03-2008, 09:56 PM
24 posts and you dont know how to post??

at least tell us if you are compiling for a microcontroller, let alone the chip, the compiler or the language?? :evil: :evil:

04-03-2008, 11:42 PM

04-04-2008, 06:15 PM
Sry for that...........

I am writing a programme for Mega32 & I am using CodeVisionAVR.
I got a programme of display on television from the Internet.........
When I compile I am getting an error that is "global variable out of SRAM".

04-05-2008, 06:09 PM
The problem is that, one of the variables in your code is consuming more memory then the data stack size (default 512 bytes). The data stack size should not exceed 2KB (for the Mega32), because of the physical RAM limitation. If you are using constant data, then you can use the flash memory (which is more abundant) for storing it.

You will get an error with the above code. Which you can fix, by adding the "flash" keyword.


Alternately, if you are going to be using non-constant data, then you will need to alter the stack size in "Project -> Configure"



Debu :)

04-05-2008, 10:59 PM
Hey, thanks for reply.............

But I think I am gettin a problem that is Uninitialized flash memory......
I have dont the following thing chk out.
http://img517.imageshack.us/img517/7024/66518669ia7.th.jpg (http://img517.imageshack.us/my.php?image=66518669ia7.jpg)

http://img164.imageshack.us/img164/8163/40466263ic6.th.jpg (http://img164.imageshack.us/my.php?image=40466263ic6.jpg)

Plz help me out.................What I have done is I have put "flash Char"
where ever there was error that is "global variable out of SRAM".

04-05-2008, 11:08 PM
Chip: ATmega32
Program type: Application
Memory model: Small
Optimize for: Size
(s)printf features: int, width
(s)scanf features: int, width
Promote char to int: No
char is unsigned: Yes
8 bit enums: Yes
Enhanced core instructions: On
Automatic register allocation: On

1472 line(s) compiled
4 error(s)
No warnings

Bit variables size: 0 byte(s)

Data Stack area: 60h to 25Fh
Data Stack size: 512 byte(s)
Estimated Data Stack usage: 0 byte(s)

Global variables area: 260h to 8C6h
Global variables size: 1639 byte(s)

Hardware Stack area: 8C7h to 85Fh
Hardware Stack size: -103 byte(s)

Heap size: 0 byte(s)

EEPROM usage: 0 byte(s) (0.0% of EEPROM)

I am getting the above error marked in red. that is -103bytes.

04-06-2008, 12:38 PM
@b_7e72003: The error means that you are using 103 bytes more then the available resources. Upload your project files, so we can try and fit it in a mega 32.

Debu :)

04-07-2008, 12:05 AM
Hey debu,

Here is the code http://instruct1.cit.cornell.edu/courses/ee476/video/Video32v3.c

Here is the thing I hav done to remove the problem!!

http://img412.imageshack.us/img412/3421/onlinecs2.th.jpg (http://img412.imageshack.us/my.php?image=onlinecs2.jpg)

In this I hav changed 3 things
1) data stack size : 100
2) signing the char
3) optimize for speed.

Then the problem of "global variable out of SRAM" is gone but its giving a warning that is "Unrefrenced global variable" but I am able to make the file.

-----> The one thing I want to know is what happens if we reduce the "data stack size".

Coz I am integrating this video code for my program. There I am getting many errors of "global variable out of SRAM" Then I did the same thing reducing the "data stack size" to remove that problem.

So I wanna know the effect of the "data stack size".

thanking you,