Registers of an Embedded Microcontroller- Explained


In this article, we go over what registers and what they are used for in embedded microcontrollers.

All microcontrollers have data memory. This is the memory that a microcontroller uses when it is executing a program that has been uploaded to it. The data memory is really the working memory during a program (code) execution.

Data memory is read/write memory, so they can be written to and read from.

The data memory of an Atmel AVR processor typically contains 3 areas of memory. The lowest section contains the 32 general-purpose working registers, followed by 64 I/O registers, then followed by the internal SRAM memory.

The working registers are used as a local storage area while the program is executing. The 64 I/O registers are used as an interface to the I/O devices and peripherals on board the microcontroller. And the internal SRAM is used as a general variables storage area and also for the processor stack.

Registers of Data Memory

As stated, the lowest section of memory contains the 32 general-purpose working registers.

Below is a diagram of the data memory of an AtMega16 processor.

Data Memory of an AtMega16 micrcontroller

You can see above how the lower section of the memory is made up of the 32 registers which act as general-purpose working registers.

The general-purpose working registers are just that- they are used for the storage of local variables and other temporary data used by the program while it is executing, and they can be used for the storage of global variables. For example, these registers are used much like the storage location in a calculator, in that they store temporary or intermediate results. Again, sometimes for local variables, sometimes for global variables, and sometimes the pointers into memory that are used by the processor. In short, the processes uses these 32 working registers as it executes the program. The use of the 32 registers is controlled by the C compiler and is typically out of the programmer's control unless assembly language is being used.

HTML Comment Box is loading comments...