Skip to main content
Steven Bébin
Associate III
August 15, 2020
Question

#define eeprom value

  • August 15, 2020
  • 4 replies
  • 1051 views

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
August 15, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
August 16, 2020
Steven Bébin
Associate III
August 16, 2020

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 III
August 16, 2020

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