cancel
Showing results for 
Search instead for 
Did you mean: 

hi guys, I'm trying to define a register range for uint32_t array. I couldn't find a place online that explain in properly. do you know a way to do so?

Gbasi.1
Associate II

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

14 REPLIES 14

You're answer's elegant. I'd mentioned structures in my post too.

But most every post to this question gets points for tenacity :)

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.

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

.

.

.

.

Gbasi.1
Associate II

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

.

.

.

.

turboscrew
Senior III

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

...

};