2020-05-20 04:11 AM
uint32_t REG_INIT[32];//// i dont think it is necessery that only for explanation
#define MainAddr ((uint64_t)0x801FEC0)
#define step 0x8
#define BiasRefInit *(uint64_t *)(MainAddr+0*step)
#define BiasRefFinal *(uint64_t *)(MainAddr+1*step)
#define PowerRecycles *(uint64_t *)(MainAddr+2*step)
#define REG_INIT[32] *(uint64_t *)(MainAddr+3*step)/// i wont to set a 32 regs range to "reg init".
2020-05-21 02:20 AM
You're answer's elegant. I'd mentioned structures in my post too.
But most every post to this question gets points for tenacity :)
2020-05-21 03:35 AM
If the registers were of different sizes, the struct is the way to go.
I just like it shorter:
uint64_t *regs = ((uint64_t *)0x801FEC0);
regs[0] = 1LL;
Now that I'm looking at it again, I wonder if the MainAddr is actually an initialization value table in flash.
In that case, there is no need to define its address, and the struct makes sense. Probably the REG_INIT values are written in the HW registers of the device, and the three other values in variables somewhere in RAM.
2020-05-21 04:05 AM
that is correct, MainAdress is the first address in Flash. i need to save a lot of different values in to flash, and keep them accessible.
the way i chose is to work is in main.h and #define with offset of MainAdress + i*step, There are few arrays that need to be store in Flash as well. what is the best way to do so? you all help me a lot and gave me lots of different way to work.
#define MainAddr ((uint64_t)0x801FEC0)
#define step 0x8
#define BiasRefInit (*(uint64_t *)(MainAddr + 0 * step))
#define BiasRefFinal (*(uint64_t *)(MainAddr + 1 * step))
#define PowerRecycles (*(uint64_t *)(MainAddr + 2 * step))
#define REG_INIT_first (*(uint64_t *)(MainAddr + 3 * step))
#define REG_Final_first (*(uint64_t *)(MainAddr + (3+32) * step))
.
.
.
.
2020-05-21 04:05 AM
that is correct, MainAdress is the first address in Flash. i need to save a lot of different values in to flash, and keep them accessible.
the way i chose is to work is in main.h and #define with offset of MainAdress + i*step, There are few arrays that need to be store in Flash as well. what is the best way to do so? you all help me a lot and gave me lots of different way to work.
#define MainAddr ((uint64_t)0x801FEC0)
#define step 0x8
#define BiasRefInit (*(uint64_t *)(MainAddr + 0 * step))
#define BiasRefFinal (*(uint64_t *)(MainAddr + 1 * step))
#define PowerRecycles (*(uint64_t *)(MainAddr + 2 * step))
#define REG_INIT_first (*(uint64_t *)(MainAddr + 3 * step))
#define REG_Final_first (*(uint64_t *)(MainAddr + (3+32) * step))
.
.
.
.
2020-05-21 05:19 AM
In that case, the easiest way would be defining a struct or array as const. Consts are (usually) located in flash.
Like:
(the underscores should be blanks, but these pages...)
const uint64_t init_array[35] = {
____1LL, // BiasRefInit value
____2LL, // BiasRefFinal value
____3LL, //PowerRecycles value
...
};