350 of free memory isnt enough?

hi folks.

I am experiencing some strange problems in my arduino..

My sketch is big... It have about 28k and when I Run the freememory function, it returns me about 350 off free memory.

What happen is in my variables..

Example:
I have one (byte vscreen = 5) and when I print to my serial, the first 10 seconds aproximatelly it runs fine, bjt after that.. It returns to 0 and the arduino crashes.

And the problem happen with some other variables as well...

What could be wrong?

any idea will be apreciated,, :slight_smile:

And the problem happen with some other variables as well...

A memory shortage may be your problem, probably caused by the 'other variables', however I might have more useful help if I didn't have to guess.

Hard to tell w/o seeing any of your code...
Are you doing any dynamic memory allocation and clearing (either manually with malloc and free, by using the String object, or something else)? Any array overruns? Using goto and letting the stack overflow? I could keep going. We really need to see code.

pYro_65:

And the problem happen with some other variables as well...

A memory shortage may be your problem, probably caused by the 'other variables', however I might have more useful help if I didn't have to guess.

Hi. Tks

What do you mean by memory shortage may be my problem.

The code wont work because Im using sensors and the sketch is about 28k...

Its like for some reason the global scope variables are losing its values...

:frowning:

Sembazuru:
Hard to tell w/o seeing any of your code...
Are you doing any dynamic memory allocation and clearing (either manually with malloc and free, by using the String object, or something else)? Any array overruns? Using goto and letting the stack overflow? I could keep going. We really need to see code.

Actually I am using some String objects and not sure if Iam using dynamic allocation, the variables are declared globally like int value_1 =350..

Could it be a memory problem?

The point is if you don't post your sketch only guesswork is available. Perhaps
you want more than guesswork?

cabecinhas:
Actually I am using some String objects and not sure if Iam using dynamic allocation, the variables are declared globally like int value_1 =350..

Could it be a memory problem?

Absolutely, the most common space-leak in fact. But that's guesswork.

Hi Folks..

First of all , thank you all for the help!

Well.. After all I jave removed all String objects because maybe it could let the atmega328 unstable.

Now I'm using about 90% of flash memory and have 500bytes of free memory.

The problem still happens..a int variable keeps losing its value and becoming values like 12736 and sometimes different numbers..

This value comes from a EEPROM ...

here's part of code:

			char buffer_envio_i2c[40];
			char vbuffer_para_float_climb[10];
			sprintf(buffer_envio_i2c, "%s,%d,%d,%d,%d", dtostrf(vclimb_smooth, 5, 2, vbuffer_para_float_climb), alerta_descentente, alerta_ascendente, parametro_diverso_modulo_beep, vtom_beep);
Wire.beginTransmission(7); // transmit to device #4
			Wire.write(buffer_envio_i2c);        // sends five bytes
			Wire.endTransmission();    /

the problem is with the vtom_beep (LAST VALUE)variable that losses its value that was supose to be 0.

There is no other place in code where I write into the vtom_beep variable..

Here's what its like here:

int vtom_beep;
void setup()
{
....
vtom_beep = EEPROM.read(1);
....
}

Any Idea about what could be wrong?

This thing is driving me crazy!!!

Tks a lot

cabecinhas:
the problem is with the vtom_beep (LAST VALUE)variable that losses its value that was supose to be 0.

There is no other place in code where I write into the vtom_beep variable..

The question is what writes to the variables next to vtom_beep. Sounds like you are overwriting something. Without all the code it is impossible to tell.

here's part of code:

Here's part of the answer. You need to...

This thing is driving me crazy!

yeah, me too.

POST YOUR CODE.