Hi all,
I have a small table of data (uint16_t type) stored in EEPROM, like this:
static const uint16_t data[] EEMEM = {
0x8030, 0x0018, 0x8018, 0x0018, 0x8030, 0x0018, 0x8030, 0x0018,
////// snip //////
0x8030, 0x0018, 0x8018, 0x0018, 0x8030, 0x0018, 0x8030, 0x0018,
};
I try to access the data like this:
for (x = 0; x < len; x++) {
value = eeprom_read_word ((const uint16_t *)(data + x));
// do stuff with "value"
}
Of course, "len" is the length of the array in words, obtained like this:
len = (sizeof (data) / sizeof (*data));
Problem is, the reads don't work!!! But, if I change everything to "uint8_t" and use "eeprom_read_byte" then it does work.
I know my code is OK because as a test I also tried it on a MEGA2560... worked fine in 16 bits.
So what the heck??? Why won't it work on the ATTiny85? Does the '85 only support byte reads of eeprom?
By the way, this is how the eeprom is getting into the '85 (from the Makefile):
[b]%.eep: %.elf
@$(OBJCOPY) \
-O ihex \
-j .eeprom \
--set-section-flags=.eeprom=alloc,load \
--no-change-warnings \
--change-section-lma .eeprom=0 \
$< $@
[/b]
And lastly, I'm using AVR-GCC 4.9.4
[b]root@michael:/usr/share/arduino-1.0.6/sketches/ee_test# avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/avr/4.9.4/lto-wrapper
Target: avr
Configured with: ../configure --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
Thread model: single
gcc version 4.9.4 (GCC)[/b]
Any ideas... I'll greatly appreciate it.