Reputation: 13
I am running this c program in gcc. The below works for one variable.
#define dataBlk_tx0 ((volatile unsigned int *) 0x20000ACB)
But if I want to create an array and write to it how would I do this, this array needs to be defined before main?
#define dataBlk_tx0 ((volatile unsigned int * x[8]) 0x20000ACB)
main{
dataBlk_tx0[0] = 5;
}
Upvotes: 1
Views: 330
Reputation: 1350
If you want to read or write directly to that address and memory, you can do it like this:
dataBlk_tx0
as a pointer to the specific memory locationvolatile unsigned int * dataBlk_tx0 = (unsigned int *)0x20000ACB;
int main () {
dataBlk_tx0[0] = 5;
return 0;
}
If you want to create an array in a specific memory region (like Flash vs RAM on a micocontroller), then you'll need to look into linker scripts.
Upvotes: 2