volatile uint32_t * sdramData = (volatile uint32_t *)0x30000100;
#define WIDTH 800
volatile uint32_t * im[WIDTH/4] = (volatile uint32_t **)sdramData;
The third line is the one giving me an error. I’m trying to make an array of int pointers that start at the location of sdramData. It’s saying an invalid initializer error. Thanks for any help.
The initializer notation needs to be enclosed in braces and the values in the braces must be constants:
This would initialize the first element of the array if
sdramDatawas a constant (it isn’t within the meaning of the term) and leave the others zeroed.If you really want 200 consecutive 4-byte locations (about which I have my doubts — see below), you’re going to have to produce 200 values to initialize the list (as standard C still doesn’t have a repeat-count option for array initializers, sadly — GCC does, as an extension).
Not pretty, but saves a lot of typing. You can insert a
(volatile uint32_t *)cast on theINIT_xexpansion if you need it — you likely do.An alternative interpretation
On the other hand, you can probably write an expression that simply uses SDRAMBASE to do the job without the array
im:Now you can write (round brackets instead of square):
instead of:
In fact, you might even use:
and then you can write (square brackets as usual):
This looks more plausible as the desired effect. Still not entirely nice, but relatively clean.