Complete introduction to Microcontrollers - Microcontrollers at a next level

Complete introduction to Microcontrollers - Microcontrollers at a next level
Intel 8049 Microcontroller

Even at a time when Intel presented the first microprocessor with the 4004 there was alrady a demand for microcontrollers: The contemporary TMS1802 from Texas Instruments, designed for usage in calculators, was by the end of 1971 advertised for applications in cash registers, watches and measuring instruments. Basically, A microcontroller is a processor with memory and a whole lot of other components integrated on one chip. The TMS 1000, which was introduced in 1974, already included RAM, ROM, and I/O on-chip and can be seen as one of the first microcontrollers, even though it was called a microcomputer. The first controllers to gain really widespread use were the Intel 8048, which was integrated into PC keyboards, and its successor, the Intel 8051, as well as the 68HCxx series of microcontrollers from Motorola.
Today, microcontroller production counts are in the billions per year, and the controllers are integrated into many appliances we have grown used to, like

  • household appliances (microwave, washing machine, coffee machine, . . . )
  • telecommunication (mobile phones)
  • automotive industry (fuel injection, ABS, . . . )
  • aerospace industry
  • industrial automation
  • ...

But what is this microcontroller we are talking about? What is the difference to a microprocessor? And why do we need microcontrollers in the first place? To answer these questions, let us consider a simple toy project: A heat control system. Assume that we want to
  • periodically read the temperature (analog value, is digitized by sensor; uses 4-bit interface),
  • control heating according to the temperature (turn heater on/off; 1 bit),
  • display the current temperature on a simple 3-digit numeric display (8+3 bits),
  • allow the user to adjust temperature thresholds (buttons; 4 bits), and
  • be able to configure/upgrade the system over a serial interface.

So we design a printed-circuit board (PCB) using Zilog’s Z80 processor. On the board, we put a Z80 CPU, 2 PIOs (parallel I/O; each chip has 16 I/O lines, we need 20), 1 SIO (serial I/O; for communication to the PC), 1 CTC (Timer; for periodical actions), SRAM (for variables), Flash (for program memory), and EEPROM (for constants).1 The resulting board layout is depicted in Figure 1.1; as you can see, there are a lot of chips on the board, which take up most of the space (euro format, 10 × 16 cm).
Z80 board layout for microcontroller
Incidentally, we could also solve the problem with the ATmega16 board we use in the Microcontroller lab. Here you can see the corresponding part of this board superposed on the Z80 PCB. The reduction in size is about a factor 5-6, and the ATmega16 board has even more features than the Z80 board (for example an analog converter)! The reason why we do not need much space for the ATmega16 board is that all those chips on the Z80 board are integrated into the ATmega16 microcontroller, resulting in a significant reduction in PCB size.
This example clearly demonstrates the difference between microcontroller and microprocessor: A microcontroller is a processor with memory and a whole lot of other components integrated on one chip. The example also illustrates why microcontrollers are useful: The reduction of PCB size saves time, space, and money.
The difference between controllers and processors is also obvious from their pinouts. All of the examples shows the pinout of the Z80 processor. You see a typical processor pinout, with address pins A0- A15, data pins D0-D7, and some control pins like INT, NMI or HALT. In contrast, the ATmega16 has neither address nor data pins. Instead, it has 32 general purpose I/O pins PA0-PA7, PB0-PB7, PC0-PC7, PD0-PD7, which can be used for different functions. For example, PD0 and PD1 can be used as the receive and transmit lines of the built-in serial interface. Apart from the power supply, the only dedicated pins on the ATmega16 are RESET, external crystal/oscillator XTAL1 and XTAL2, and analog voltage reference AREF.
Now that we have convinced you that microcontrollers are great, there is the question of which microcontroller to use for a given application. Since costs are important, it is only logical to select the cheapest device that matches the application’s needs. As a result, microcontrollers are generally tailored for specific applications, and there is a wide variety of microcontrollers to choose from.
The first choice a designer has to make is the controller family – it defines the controller’s architecture. All controllers of a family contain the same processor core and hence are code-compatible, but they differ in the additional components like the number of timers or the amount of memory. There are numerous microcontrollers on the market today, as you can easily confirm by visiting the webpages of one or two electronics vendors and browsing through their microcontroller stocks. You will find that there are many different controller families like 8051, PIC, HC, ARM to name just a few, and that even within a single controller family you may again have a choice of many different controllers.
 Comparison of AVR 8-bit controllers
Table 1.1 shows a selection of microcontrollers of Atmel’s AVR family. The one thing all these controllers have in common is their AVR processor core, which contains 32 general purpose registers and executes most instructions within one clock cycle.
After the controller family has been selected, the next step is to choose the right controller for the job (see [Ber02] for a more in-depth discussion on selecting a controller). As you can see in Table 1.1 (which only contains the most basic features of the controllers, namely memory, digital and analog I/O, and interfaces), the controllers vastly differ in their memory configurations and I/O. The chosen controller should of course cover the hardware requirements of the application, but it is also important to estimate the application’s speed and memory requirements and to select a controller that offers enough performance. For memory, there is a rule of thumb that states that an application should take up no more than 80% of the controller’s memory – this gives you some buffer for later additions. The rule can probably be extended to all controller resources in general; it always pays to have some reserves in case of unforseen problems or additional features.
Of course, for complex applications a before-hand estimation is not easy. Furthermore, in 32- bit microcontrollers you generally also include an operating system to support the application and its development, which increases the performance demands even more. For small 8-bit controllers, however, only the application has to be considered. Here, rough estimations can be made for example based on previous and/or similar projects.
The following list contains the modules typically found in a microcontroller. You can find a more detailed description of these components in later sections.
  • Processor Core: The CPU of the controller. It contains the arithmetic logic unit, the control unit, and the registers (stack pointer, program counter, accumulator register, register file, . . . ).
  • Memory: The memory is sometimes split into program memory and data memory. In larger controllers, a DMA controller handles data transfers between peripheral components and the memory.
  • Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case of (important) external or internal events. In conjunction with sleep modes, they help to conserve power.
  • Timer/Counter: Most controllers have at least one and more likely 2-3 Timer/Counters, which can be used to timestamp events, measure intervals, or count events. Many controllers also contain PWM (pulse width modulation) outputs, which can be used to drive motors or for safe breaking (antilock brake system, ABS). Furthermore the PWM output can, in conjunction with an external filter, be used to realize a cheap digital/analog converter
  • Digital I/O: Parallel digital I/O ports are one of the main features of microcontrollers. The number of I/O pins varies from 3-4 to over 90, depending on the controller family and the controller type.
  • Analog I/O: Apart from a few small controllers, most microcontrollers have integrated analog/digital converters, which differ in the number of channels (2-16) and their resolution (8-12 bits). The analog module also generally features an analog comparator. In some cases, the microcontroller includes digital/analog converters.
  • Interfaces: Controllers generally have at least one serial interface which can be used to download the program and for communication with the development PC in general. Since serial interfaces can also be used to communicate with external peripheral devices, most controllers offer several and varied interfaces like SPI and SCI. Many microcontrollers also contain integrated bus controllers for the most common (field)busses. IIC and CAN controllers lead the field here. Larger microcontrollers may also contain PCI, USB, or Ethernet interfaces.
  • Watchdog Timer: Since safety-critical systems form a major application area of microcontrollers, it is important to guard against errors in the program and/or the hardware. The watchdog timer is used to reset the controller in case of software “crashes”.
  • Debugging Unit: Some controllers are equipped with additional hardware to allow remote debugging of the chip from the PC. So there is no need to download special debugging software, which has the distinct advantage that erroneous application code cannot overwrite the debugger
Ahh... Wait, where are you going, this is the first introductory tutorial of Microcontrollers. All the giant stuff is waiting for you just a step ahead. To achieve that milestone, subscribe to our blog and be a part of the community of new generation technical education. And the further tutorials are coming up, just hold on your chairs...

Comments

Popular Posts