8.12.1 Accessing 16-Bit Register
Most registers in AVR16LA14/20/28/32 devices are 8-bit registers, but they also feature a few 16-bit registers. Since the AVR data bus has a width of eight bits, accessing 16-bit requires two read or write operations. All 16-bit registers in AVR16LA14/20/28/32 devices are connected to the 8-bit bus through a temporary (TEMP) register.
For a 16-bit write operation, the low-byte register (for example, DATAL) of the 16-bit register must be written before the high-byte register (for example, DATAH). Writing the low-byte register results in a write to the temporary (TEMP) register instead of directly to the low-byte register, as shown on the left side of the figure above. When the high-byte register of the 16-bit register is written, the content of TEMP are copied into the low-byte of the 16-bit register in the same clock cycle, as shown on the right side of the figure.
For a 16-bit read operation, the low-byte register (for example, DATAL) of the 16-bit register must be read before the high-byte register (for example, DATAH). When the low-byte register is read, the high-byte register of the 16-bit register is copied into the temporary (TEMP) register in the same clock cycle, as shown on the left side of the figure above. Reading the high-byte register then returns the value from TEMP instead of the high-byte register, as shown on the right side of the same figure.
The described mechanism ensures that the low and high bytes of 16-bit registers are always accessed simultaneously when reading from or writing to the registers.
Interrupts can corrupt the timing sequence if an interrupt is triggered during a 16-bit read or write operation and a 16-bit register within the same peripheral is accessed in the interrupt service routine. To prevent this, it is recommended to disable interrupts when reading from or writing to 16-bit registers. Alternatively, the temporary register can be read before and restored after the 16-bit access in the interrupt service routine.
