2020-06-07 02:04 AM
I want to define array [32] at a specific address. This is what I wrote:
#define Step 0x8
#define MainAddress 0x801F800
#define BiasRefInit *(uint64_t *)(MainAddress+ 0*Step)
#define InterREGdelVAL100u *(uint64_t *)(MainAddress+ 1*Step)
#define GaveFactor *(uint64_t *)(MainAddress+ 2*Step)
#define GaveFactorCount *(uint64_t *)(MainAddress+ 3*Step)
#define PowerRecycles *(uint64_t *)(MainAddress+ 4*Step)
#define REG_INIT_FIRST *(uint64_t *)(MainAddress+ 5*Step)
#define MyArray *(uint64_t (*)[32])(MainAddress+ 5*Step)
I cannot access the values in the array but only the whole array. Although the IDE shows me all the (correct) values in the array:
snprintf(string, 8, "%06X", MyArray);
what should i do?
2020-06-07 05:07 AM
>>what should i do?
Perhaps use a less hacky approach and use C structures and pointer instead?
For a singular pointer
uint64_t *MyArray= (uint64_t *)(MainAddress+ 5*Step); // An array, at an address
int i;
printf("%p\n", MyArray); // The pointer
for(i=0; i<32; i++)
printf("%d\n", (int)MyArray[i]); // The content
I'd use a structure to define index content with multiple records.
Stop using this ugly #define method, and find ways to use the C language