I've heard of 8 bit microcontrollers and 16-bit microcontrollers. I've even heard about 7 bit microcontrollers and 1 bit microcontrollers.
What are the general attributes of these groups? How do I choose which type to use for a project?
I've heard of 8 bit microcontrollers and 16-bit microcontrollers. I've even heard about 7 bit microcontrollers and 1 bit microcontrollers.
What are the general attributes of these groups? How do I choose which type to use for a project?
There are also 4-bit and 32-bit microcontrollers. 64 bit microprocessors are used in PCs.
The number refers to the register width. The registers are at the heart of the microcontroller. Many operations use registers, either to move data or to do arithmic or logical operations. These operations take place in the ALU, the Arithmetic and Logic Unit.
Some operations take only 1 argument, like clearing a register, or incrementing it. Many, however, will take 2 arguments, and that leads to the typical upside-down trousers representation of an ALU. \$A\$ and \$B\$ are the arguments, and the ALU will produce a result \$C\$ based on the current operation. A two-argument operation may be "add 15 to register R5 and store the result at memory address 0x12AA". This requires that there's a routing between the constant "15" (which comes from program memory), the register file and data memory. That routing occurs through a databus. There's an internal databus connecting the registers, internal RAM and the ALU, and for microprocessors and some microcontrollers an external databus which connects to external RAM. With a few exceptions the databus is the same width as the registers and the ALU, and together they determine what type of microcontroller it is. (An exception was the 8088, which internally has a 16-bit bus, but externally only 8-bit.)
4-bit controllers have 4-bit registers, which can only represent 16 different values, from 0 to hexadecimal 0xF. That's not much, but it is enough to work with the digits in a digital clock, and that's a domain where they're used.
8-bit controllers have been the workhorse of the industry for a couple of decades now. In 8 bits you can store a number between 0 and 255. These numbers can also represent letters and other characters. So you can work with text. Sometimes 2 registers can be combined into a 16-bit register, which allows numbers up to 65535. In many controllers large numbers have to be processed in software though. In that case even 32-bit numbers are possible.
Most 8-bit controllers have a 16-bit program counter. That means it can address maximum 64kBytes of memory. For many embedded applications that's enough, some even need only a few kBytes.
A parking lot monitor, for instance, where you have to keep count of the number of cars and display that on an LCD, is something you typically would do with an 8-bit controller. :-)
16-bit is a next step. For some reason they never had the success 8-bitters or 32-bitters have. I remember that the Motorola HC12 series was prohibitive expensive, and couldn't compete with 32-bit controllers.
32-bit is the word of the day. With a 32-bit program counter you can address 4GByte. ARM is a popular 32-bit controller. There are dozens of manufacturers offering ARMs is all sizes. They're powerful controllers often having lots of special functions on board, like USB or complete LCD display drivers.
ARMs often require large packages, either to accomodate for a large die with a lot of Flash, or because the different functions require a lot of I/O pins. But this package illustrates the possibilities ARM offers.
This is a 16-pin ARM in a package just 2.17mm x 2.32mm.
The simple answer: An N-Bit microcontroller has a data path and ALU that can process data in N-Bit chunks.
Long answer: The short answer is correct 95% of the time. The long answer gets confusing. Some CPU/MPUs have parts that are mostly N-Bits, but some parts are M-Bits. For example, it might be an 8-bit CPU with an integer multiplier that works on 16 bit data. The Intel series of CPU's (8088 through the current i7) could often combine various 8 and 16 bit registers to get 16 or 32 bits. Then the marketing people get these numbers and decide to use them in their marketing stuff and you end up with 8-bit MPUs called 16 bits, etc.
It gets even more weird than that. Some marketing people promote the instruction size of the MPU. The Microchip PICs are a good example of this. If you're not careful then you might confuse this with the number of bits in the data path.
Sorry if this first paragraph is a little too low-level, but it's offered in the hope that it can help future readers: A number, represented by N digits in base M, can only be as large as \$M^N\$. For example, with 9 decimal (base 10) digits, you can only write down numbers up to 10^9, or zero to 999,999,999. With 8 binary (base 2) digits (a "Binary digIT" is a 'bit'), you can store 2^8 = 256 numbers.
A microcontroller or processor is called 'N-bit' because controllers and processors have a fundamental data width. Each register might be N bits, each instruction might be N bits, the data bus might be N bits, the memory might be addressed with N bits. Especially at the lower level, there are exceptions to this rule: for example, an 8-bit controller might have a 12-bit memory bus, but as you might guess that's hard to work with when your registers only contain 8 bits. However, all processors have a fundamental native data type width. Consider the following code:
uint32_t x,y,z; // Declare 3 32-bit variables
z=x + y; // Add two of them to store in the third
If you can only add 8-bit numbers, how would you perform this operation? You would need to break each variable into 4 8-bit numbers, do the additions and carries individually, and then merge them to get the result. This would take at least 16 instructions! However, on a 32-bit processor, it's a single instruction as simple as mul r0, r1, r2
. As you can see from this simple example, larger processor bit widths can handle more data faster.
The trend throughout history has been from smaller bit widths towards larger ones. Way back in the early 1970s, Intel released the 4004, the first single-chip controller. It was a 4-bit processor. Because transistors were large and power-hungry, and because the design was revolutionary and complicated, this was all that could be squeezed onto the chip. Shortly thereafter, they released the 8008, an 8-bit processor. There are few 4-bit processors still in use, but there are many 8-bit controllers, the PIC and AVR are contemporary examples still in common use. More 8-bit processors have been made than any other type! They're still the most popular controllers for small, simple, and cost-sensitive tasks. The next obvious transition was to 16-bit controllers, but these haven't had the reach of their 8-bit or 32-bit brethren. Instead, there's been a jump to 32-bit processors, like those designed by ARM and designed into the PC CPUs of a few years ago. There haven't been any significant 64-bit microcontrollers that I'm aware of, though they are now prominent in PCs.
By far, the most popular types are the 8-bit and 32-bit processors. The 32-bit processors are becoming more and more popular. Every year or so, some trade magazine publishes an article with the title "Is 8-bit dead?" 32-bit processors are becoming more popular, more powerful, and cheaper, leaving only three reasons to choose an 8-bit processor:
32-bit processors are becoming more ubiquitous, but there's little sign that the 8-bit processor will disappear like the antique 4-bit processors because of these three reasons.
Consider an application like the Arduino.
The Arduino uses an Atmel controller, an 8-bit ATmega32. The ATmega runs at 20 MHz, has 4k of RAM, has SPI, I2C, and UART communications, a few hardware interrupts, and 8 10-bit ADCs. This chip costs $3.90 in quantities of 100.
A similar 32-bit chip could be another Atmel part, a 32-bit AT-SAM3 using the shared ARM Cortex-M3 core. This chip runs at 64 MHz (3x as fast, but remember that the ATmega takes 16 instructions to do a single 32-bit addition). It has 16k of RAM, 4 times as much as the ATmega. It has I²C, MMC, SPI, SSC, UART, and even USB peripherals. It has DMA (direct memory access, also makes it faster and more efficient), a flexible, powerful set of interrupts, 10 12-bit ADCs and 2 DACs. It simply outclasses the ATmega in all categories. I tried to find a 32-bit controller that had a comparable feature set, and this was the best I could do. How much does this chip cost? It's $2.34 in quantities of 100: You get more performance for less money. Should be an easy decision.
For your example situation here,
The number of cars going in and out of a car park must be counted and the number displayed on a LCD screen. A maximum of ten cars are allowed into the car park.
you have some very simple math with small numbers and a simple display on an LCD (or really, a large sign made of 7-segment LED-lit numbers would be more visible and cheaper). An 8-bit controller is probably perfectly adequate for this task. However, what if you really do want an LCD? The 8-bit controller will struggle to drive even a low-resolution VGA display, while you can easily get development boards for 32-bit controllers that have HDMI outputs. What if you want to display it on a screen for now, but later want to connect it to an Ethernet cable on your business' LAN and display the results on the supervisor's computer at the park office? You can easily get 32-bit controllers with on-board Ethernet communication busses, you can't do that with an 8-bit controller. You could buy something like an Xport, but that contains a 32-bit processor inside it.
For one-off projects, I'd recommend a 32-bit controller every time. Your time is simply more valuable than the price difference between 8- and 32-bit controllers.
With respect to the 7-bit processors you mentioned, there probably have never been and never will be any such machines. From an architectural standpoint, it's more sensible to use bit widths that are powers of 2.
The bit-size of a CPU relates to a few characteristics which generally go together:
For some processors, all of those quantities have the same value. For others, they may have different values. The Z80, although it includes some 16-bit registers, uses 8-bit registers for most of its instruction set, and requires extra cycles for almost all instructions that operate on 16-bit quantities (the only exception being EX DE,HL); it is an 8-bit CPU. Something like the 68008, however, cannot be very well described using just one N
: it has an instruction set which can mostly operate on 32-bit quantities, and it can IIRC move data between registers 32 bits at a time, but its primary ALU is only 16 bits, and its memory bus is only 8 bits. Depending upon what one is measuring, it could be regarded as a 32-bit, 16-bit, or 8-bit CPU.