The Flash memory in AVR is divided into 16-bit words. This means that each Flash address location can store two bytes of data. For an ATmega128, it is possible to address up to 65k words or 128k bytes of Flash data. In some cases the Flash memory is referred to by using word addressing and in other cases by using byte addressing, which can be confusing. All functions contained in this application note use byte addressing. The relation between byte address and word address is as follows:
Byte address = word address • 2
A Flash page is addressed by using the byte address for the first byte in the page. The relation between page number (ranging 0, 1, 2…) and byte address for the page is as follows:
Byte address = page number • page size (in bytes)
Example on byte addressing:
A Flash page in an ATmega128 is 256 bytes long.
When addressing a page in ATmega128, the lower byte of the address is always zero. When addressing a word, the LSB of the address is always zero.