On Tue, 2009-05-26 at 10:46 +1000, Michael wrote: > I think I may know the problem. > > Not only are your strings are stored in program memory, but also your > pointers to these strings are stored in program memory.
Thanks Michael and others who bothered to reply, indeed, I borked up the access to program space, as many have kindly pointed out, but more interestingly: uint8_t k = 1; uint8_t l = now.dow; // will be 1 at runtime lcd_write_int16(dow[k]); // outputs: address of dow[1] in PGM lcd_write_int16(k==l); // outputs: 1 (as it should) lcd_write_int16(dow[l]); // outputs: 0 Turns out that GCC optimizes out k and replaces dow[k] with the appropriate value from array initializer. At runtime, dow[l] is (correctly) dereferenced to data space, while dow[k] has been substituted with a hardcoded pointer to program space at compile-time. Lesson learned. =) Zoran _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list