What This Means and How to Adapt

If existing assembly code that writes to Flash is to be ported from older devices to tinyAVR 1-series devices, the SPM instructions must be replaced by ST instructions. The ST instruction will not be able to access Flash directly, but instead data will be written to the page buffer. This is similar to how it has been done previously, but now page erase and page commits are handled by the NVM controller.

Where one would previously store the address to a page in Flash in the Z-pointer, this is now handled by an Address register in the NVM controller. Note that the Address register in the NVM controller is updated automatically when data is written using the ST instruction. Do not write data to a new page before committing the page buffer. If this is accidentally done, the data intended to be written to the new page will be combined with the data already in the page buffer using a bit-wise AND. The same will happen if data is written to the same address twice without committing the page buffer.

Along with the addresses, the commands to erase a page or write the page buffer are now also located in the NVM controller. The commands should now be written to the Control A register in the NVM controller. See the Control A register in the datasheet for a list of the available commands.

These changes make it necessary to modify code written in C or assembly for older tinyAVRs in order for it to function properly on tinyAVR 1-series devices. Example code is available from Atmel | START that shows how to read and write to both flash and EEPROM on tinyAVR 1-series devices.