In my embedded c program I have a struct:
struct var{
unsigned long value;
unsigned long length;
+ More
}
An array of these structs is used to hold variables. Most of the variables stored are simply stored in 'value' and so the length is set to 1.
However, some of these variables are arrays and Im trying to store the start address in 'value'.
unsigned long lookup[10];
variables[x].length = 10;
Then I'm not quite sure how to store the address...
variables[x].value = lookup;
// lookup is a pointer so I cant put it into value
OR
variables[x].value = (unsigned long)lookup;
// value reads back through sprintf+uart as '536874692'
// which couldnt be a valid memory address!
I might just give up and add a pointer variable in the structure
EDIT:
I wanted to avoid adding the pointer to the struct becasue I would have to go back and rewrite the flash read/write functions to also save the pointer. These are pretty complicated and currently work so I'd rather not touch them!