Const struct at a specified Address

Jul 27, 2022
Reaction score
Hey guys ,
how do I create or initialize a constant structure at an address in a microcontroller(in C)?
I want the structure to be at that position it self. so I tried like this
#define ADDRESS (0x7FC)
typedef const struct
uint8_t first;
uint8_t second;
uint8_t third;
} structure;
#define REGS ((structure*)ADDRESS)
structure *structname = REGS;

but need to initialize in the main as structname->first=1 . I don't want that. I want the compiler to directly load the values at that address. How can we do that?


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question