How do i rewrite the program so that i write unsigned int values that are in an array, to
the ext. memory, and and read them out later.
If the array of ints is not too big, you can make a union with a char array, then write the char to the EEPROM. Then you read the chars back into the union and you can access the data as ints from the other side of the union.
For instance:
// Assume there are "n" ints to be stored
// Make a union of the n ints, and a char buffer of size 4*n
typedef union {
struct {
// param lists Byte offset
int variable_1; // 0 to 3
int variable_2; // 4 to 7
int variable_3; // 8 to 11
. . .
int variable_n-1; // 4(n-2) to (4n -5)
int variable_n; // 4(n-1) to (4n -1)
} varlist;
char cp[4n];
} ptr;
} _EEPROM_PARAMS;
// Create a corresponding parameter set
_EEPROM_PARAMS p;
// Write and read the variables as follows
p.varlist.variable_1 = something;
somethingelse = p.varlist.variable_2;
// Write and read the EEPROM as follows
for(i = 0; i < 4n; i++) {
sram.write(i, p.ptr.cp[i]);
}
sram.read(0, p.ptr.cp, 4n);
The usual disclaimers: I haven't tested or compiled. But I have used something similar in my own projects, so this should work for you, too.
[Edits] A bunch of typos...and Andy's method seems more elegant in any case.
Hi all,
I hooked up a microchip 23K256 (32 KB) to the Mbed. I used this programm:http://mbed.org/users/romilly/programs/Ser23K256/5z0rr
But no data is written to the memory. thus no output. Checked wiring three times, thats oke
Any suggestions ?
greets,
Marcel