I'm trying to improve my coding practice for embedded. The code below writes the value 0 to the memory location 0x80001000.
#define MemoryWrite(A,V) *(volatile unsigned long*)(A)=(V)
#define FLAG 2147487744 //0x80001000
uint32_t reset_value = 0;
int main(void)
{
MemoryWrite(FLAG, reset_value);
return 0;
}
I have two questions:
In order to use the
MemoryWritemacro I had to convert0x80001000to2147487744. I think this makes the code unclear. Is there a way that I could do this just using the hex value?I defined
reset_valueas auint32_t. What would it change if I used#defineinstead ?