Skip to main content
Steven Bébin
Associate III
Aug 15, 2020 5:23 PM UTC
Question

#define eeprom value

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

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
Aug 15, 2020 6:00 PM UTC

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
Aug 16, 2020 7:28 AM UTC
Steven Bébin
Associate III
Aug 16, 2020 7:54 AM UTC

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
Super User
Aug 16, 2020 8:14 AM UTC

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...