cancel
Showing results for 
Search instead for 
Did you mean: 

hi guys. I'm using stm32l412kb and working with STM32CubeIDE 1.3.0. I use to use this function when I worked with 8051: xdata u8 REG_INIT[32] _at_ RAM_Image+0x0020; and I'm looking for an alternative function

Gbasi.1
Associate II

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

0693W000001qBiRQAU.jpg

what should i do?

1 REPLY 1

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..