I have been studying this for ATmega328, I first want to verify I am correct in the following. And then I have question on page write and page erase.
ATmega328 has 32K byte flash = 16K words. It is organized as 256Pages with 64Words/pages.
So you need 6 address bits for each page(64Words/page), You need 8 address bits to address 256Page.
For ATmega328, you don’t need RAMPZ register. Use Z(6..1) as WORD address within each page. Use Z(14..7) as PAGE address. Z15 and Z0 NOT USED.
I have question about SPM instruction. It supposedly can write ONE WORD or ONE PAGE. It can ERASE ONE PAGE. I really don’t know how it works. I’ve been searching and I cannot find answer.
In the copy above. Can someone post a few lines of code(IN ASSEMBLY LANGUAGE) performing in each case above using SPM instruction? I just want to see the actual code how SPM in action, what is needed to set up to use the SPM instruction.
I have been searching around with no luck.
Thanks