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.
If I don’t have RAMPZ, it should be just (Z) instead of (RAMPZ:Z)?
As above because the address is for word(not byte), Z0 is not used. I don’t understand how they can write Z+, you have to increment 2 times to increment Z1 by 1.
How do you do a page erase as shown in (i) above? In my case it should be (Z)$ffff. How is that erase a full page of 64Words. What is the Syntax using SPM instruction.
What is the Syntax o f(ii) to write one word using SPM?
How do you set up to write one page of program memory from temporary page in (iv) using SPM?
I have been searching around with no luck.
Thanks