8-bit AVR Microcontroller

Programming the Flash

The Flash can be written word-by-word. Before writing a Flash word, the Flash target location must be erased. Writing to an un-erased Flash word will corrupt its content.

The Flash is word-accessed for writing, and the data space uses byte-addressing to access Flash that has been mapped to data memory. It is therefore important to write the word in the correct order to the Flash, namely low bytes before high bytes. First, the low byte is written to the temporary buffer. Then, writing the high byte latches both the high byte and the low byte into the Flash word buffer, starting the write operation to Flash.

The Flash erase operations can only performed for the entire Flash sections.

The Flash programming sequence is as follows:
  1. 1.Perform a Flash section erase or perform a Chip erase
  2. 2.Write the Flash section word by word