cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to tell the Cosmic compiler *not* to initialize EEPROM?

Rob Klein
Associate II

In a project I'm working on, I am using the internal EEPROM of the STM8L151.

I do not initialize the variables (of course), but the compiler automatically set them all to 0. This is a bit of a problem because my code looks for 0xFF to see whether or not the variables have been previously written. And with 0 being a valid value for most of them, this distinction cannot be made.

Now, I realise that in production this is no big deal, because I can simply just not program the EEPROM, but in debugging it is a right royal pain in the neck.

I have gone through the Cosmic documentation, but couldn't find anything.

So, does anyone have a solution?

Best regards,

Rob

1 REPLY 1
Ozone
Lead II

I don't know Cosmic compiler specific, but according to the C standards, a value of 0 is assumed if you do not initialize global/static variables.

That means, outside of function scope,

int myVariable;

is equivalent to

int myVariable = 0;