Embedded System |
||
Register (General Purpose Register, Special Function Register)
Simply put, a Register is a kind of memory. Then what is it so special to have different name for it. It is because they are special memory which is different from what we normally call a Memory (e.g, Flash RAM, Program Memory etc). Usually Register is located within a CPU or MCU (Microcontroller) very near to Arithematic unit or directly connected to various I/O ports. Due to this location or special design, Register is much faster in terms of Read / Write speed comparing to other types of memory. Among the register there are roughly two groups of Registers. One is mostly used for storing (or assigning) a specific values that are used by ALU (Arithmatic Logic Unit). These registers are called General Purpose Registers. The other type of the registers is mostly used to control the various I/O pins or to read / write to those I/O pins. The one related to I/O pins are generally called I/O registers or Special Function Registers(SFR). Every CPUs and MCUs have various Registers in it but we don't usually care much of these registers when we are working on high level application programming. However, if you are an embedded system engineer working with Microcontrollers, you should be very familiar with the details of those Registers for the specific MCU (Microcontroller) that is used on your embedded board.
Then you may ask 'where/how I can get the register information about the MCU / CPU that is on my embedded Board ?'. The first document you need to see is the data sheet of the chipset. For example, if you are using Arduino board, the board is using the MCU called ATmega family. If you open up the ATmeaga datasheet you would be able to find a diagrams as shown below (I combined three different diagrams from the document to create this picture). The parts high lighted blue and red are all a kind of memory. The parts highlighted red are registers. Whenever you want to programm on a certain microcontroller, this kind of diagram would be the first one you have to visualize in your brain. When you really write a program, just this kind of big picture will not be enough. You have to read the details of each and every of these registers in the datasheet.
< Block Diagram of the AVR Architecture > Source : Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
What does Register mean to Embedded System ?
Whenever I get a new Embedded Board or try to select a microcontroller, I always try to look up two things first. One is Memory Map and the other one is Register information. I also check how well they are documented in manufacturers datasheet or user manual. If these two items are poorly documented, I would rather not pick up those board or chipset. Why I care so much about these, especially about Registers. Personally to me, Register means
Next Step :
Now you might have general feeling about what a Register is, but you would not get a real / deep insight on this unless you use the concept in your daily programming. So the next step is to utilize various registers in your program. Here goes some of my examples. From these documents, you would see overall functions of those microcontrollers looks almost same. That is, all of those microcontroller provides GPIO, UART,I2C,SPI,PWM,TIMER etc. But the number of registers and complexities of those registers varies a lot depending on each microcollers. Why ? Think about it.
Reference :
[1]
|
||