cancel
Showing results for 
Search instead for 
Did you mean: 

#define eeprom value

Steven Bébin
Associate III

Hello,

I have settings in my EEPROM. I would like to assign these parameters with a #define.

I tried several things, searched the internet, but couldn't find anything conclusive.

I found something, but it is not suitable for my program, here it is :

#define a              ((uint16_t*) ((uint32_t) 0x08080000))

It works this way :

if(*a == 1)
{
     .....
}

But it doesn't work that way which fits my program :

#if( *a == 1)
     .....
#endif

Do you know the right way to do it ? Thank you

4 REPLIES 4

Top method computes at runtime, the lower the compiler's pre-processor, at compile time. How would that possibly work?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II
Steven Bébin
Associate III

Thanks a lot for your answers.

Since I didn't want to change a big part of my program, I hoped to find a miracle solution. I thought it wasn't possible, but I hoped.

MM..1
Chief II

Steve Steve, your code isnt real. DEFINE is constant, then you cant ask for memory value.

You only for your example can have two defines, one for adr second for value.

#define ADDRa              ((uint16_t*) ((uint32_t) 0x08080000))
#define VALUEa              1

then you can use in code

*ADDRa = VALUEa;
...
 
#if VALUEa == 1
 
#endif

For some eeprom too first line dont work and need function call for write or read...