So I've finally got my precious samples of ATmega2561. With 256Kbytes of Flash I should be able to store massive look-up tables, but wait a minute the Flash memory is segmented into 64Kbyte lumps. The data sheet states:
"For ELPM/SPM instructions, the Z-pointer is a concatenation of RAMPZ, ZH, and ZL"
But is that really true? I find that I have the following instruction:
ELPM Rd,Z+
which loads register Rd from the program memory pointed to by the
24-bit concatenated Z pointer described so eloquently above. However I find that the post increment only deals with ZH & ZL. The most significant 8-bits in RAMPZ are not incremented when the ZH/ZL combination wraps around and tables must not cross a 64K boundary.Ok, I suppose the 16F84 only had 256 byte pages but that was a long time ago and I we have progressed a little since then, but clearly not as much as I thought.