Microcontroller

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar
Motorola 68HC11 microcontroller and support chips
Die of Intel 8-bit microcontroller 8742, with CPU to 12 MHz, 128 RAM bytes, 2048 EPROM bytes, and E/S on a chip
PIC 18F8720 microcontroller in 80 pin TQFP encapsulate
Microcontrolador TMS 1000 de Texas Instruments
Texas TMS 1000 Microcontroller Instruments

A microcontroller (abbreviated µC, UC or mCU) is a programmable integrated circuit, capable of executing the orders recorded in his memory. It is composed of several functional blocks that fulfill a specific task. A microcontroller includes within it the three main functional units of a computer: central processing unit, memory, and input/output peripherals.

Some microcontrollers can use four-bit words and operate at clock speeds as low as 4 kHz, with low power consumption (mW or microwatts). Typically, it will have the ability to wait for an event such as a button press or other interrupt; thus, power consumption during idle state (CPU clock and most peripherals) can be as low as nanowatts, making many of them well suited for applications with long battery life. Other microcontrollers can serve performance-critical roles, where it is necessary to act more like a digital signal processor (DSP), with higher clock speeds and power consumption.

When the microcontroller is manufactured, it does not contain data in ROM memory. In order to control a process, it is necessary to generate or create and then record a program in the EEPROM or equivalent of the microcontroller, which can be written in assembly language or another language for microcontrollers; However, in order for the program to be recorded in the microcontroller's memory, it must be coded in a hexadecimal numerical system, which is ultimately the system that makes the microcontroller work when it is powered with the proper voltage and associated with analog and discrete devices for its operation.

History

The first microprocessor was the 4-bit Intel 4004, released in 1971, followed by the Intel 8008 and more capable ones. However, both processors require additional circuitry to implement a working system, raising the total system cost.

The Smithsonian Institution says that Texas Instruments engineers Gary Boone and Michael Cochran succeeded in creating the first microcontroller, the TMS 1000, in 1971; it was commercialized in 1974. It combines ROM memory, RAM memory, microprocessor and clock on a chip and was intended for embedded systems.

Due in part to the existence of the TMS 1000, Intel developed a computer-on-a-chip system optimized for control applications, the Intel 8048, which began shipping in 1977. It combines RAM and ROM memory on the same chip and can be found in over a billion IBM PC compatible keyboards, and numerous other applications. Intel's then president, Luke J. Valenter, declared the microcontroller one of the most successful products in the company's history, and expanded the division's budget by more than 25%.

Most microcontrollers at that time had two variants. Some had a reprogrammable EPROM memory, significantly more expensive than the PROM variant that was only once programmable. To erase the EPROM you need to expose the clear quartz cap to ultraviolet light. Chips with everything opaque represented less cost.

In 1993, the release of EEPROM in microcontrollers (beginning with the Microchip PIC16x84) allows it to be quickly and electrically erased without the need for an expensive package as required in EPROM, allowing for both rapid prototyping and programming in the system. The same year, Atmel released the first microcontroller to use flash memory. Other companies quickly followed suit, with both types of memory.

Cost has plummeted over time, with the cheapest 8-bit microcontroller available for less than $0.25 for thousands of units in 2009, and some 32-bit microcontrollers at $1 for similar amounts. Today microcontrollers are cheap and readily available to hobbyists, with large online communities for certain processors.

In the future, MRAM could be used in microcontrollers, since it has infinite resistance and the cost of its semiconductor wafer is relatively low.

Features

A microcontroller. In this figure, we see the microcontroller inside an integrated circuit encapsulate, with its processor (CPU), buses, memory, peripherals and ports of entry/output. Outside the encapsulate are located other circuits to complete internal peripherals and devices that can be connected to the input/output pins. The feeding, mass, oscillator completion circuit and other circuits necessary for the microcontroller to work will also be connected to the pins of the encapsulate.

Microcontrollers are designed to reduce the economic cost and power consumption of a particular system. So the size of the central processing unit, the amount of memory and the included peripherals will depend on the application. Controlling a simple appliance like a blender will use a very small processor (4 or 8 bits) because it will replace a finite automaton. In contrast, a digital music or video player (MP3 or MP4) will require a 32-bit or 64-bit processor and one or more digital signal codecs (audio or video). The control of an ABS (Antilock Brake System) brake system is normally based on a 16-bit microcontroller, just like the electronic engine control system in a car.

Microcontrollers account for the vast majority of computer chips sold, over 50% being "simple" and the rest corresponds to more specialized DSPs. While you may have one or two general-purpose microprocessors at home (you're using one for this), you probably have a dozen or two dozen microcontrollers scattered among your household appliances. They can be found in almost any electronic device such as cars, washing machines, microwave ovens, telephones, etc.

A microcontroller differs from a normal central processing unit in that it is easier to turn into a working computer, with a minimum of external supporting ICs. The idea is that the integrated circuit is placed in the device, hooked to the source of energy and information that it needs, and that's it. A traditional microprocessor won't let you do this, as it expects all of these tasks to be handled by other chips. You have to add the input and output modules (ports) and the memory for information storage.

A typical microcontroller will have an onboard clock generator and a small amount of random access memory or ROM/EPROM/EEPROM/flash, so a few control programs and a crystal are all that are needed to get it running synchronization. Microcontrollers generally also have a wide variety of input/output devices, such as analog-to-digital converters, timers, UARTs, and specialized serial interface buses such as I2C and CAN. Frequently, these embedded devices can be controlled by instructions from specialized processors. Modern microcontrollers often include a built-in programming language, such as the BASIC programming language which is widely used for this purpose.

Microcontrollers trade off speed and flexibility for ease of use. Because quite a lot of space is used on the chip to include functionality, such as the input/output devices or the memory that the microcontroller includes, any other circuitry has to be dispensed with.

Computer architectures

There are basically two computer architectures, and of course, they are present in the world of microcontrollers: Von Neumann and Harvard. Both differ in the way memory is connected to the processor and in the buses that each one needs.

Von Neumann Architecture

The Von Neumann architecture uses the same storage device for both instructions and data, being the one used in a personal computer because it saves a good number of I/O lines, which are quite expensive, over all for those systems where the processor is mounted in some type of socket housed on a motherboard. Also this organization saves motherboard designers a lot of trouble and reduces the cost of motherboard systems.

In a personal computer, when a program is loaded into memory, it is assigned a memory address space that is divided into segments, of which we will typically have the following: code (program), data, and stack. That is why we can talk about memory as a whole, even though there are different physical devices in the system (hard disk, RAM memory, flash memory, optical disk drive...).

In the case of microcontrollers, there are two well-defined types of memory: data memory (typically some form of SRAM) and program memory (ROM, PROM, EEPROM, flash, or other non-volatile type). In this case, the organization is different from that of the personal computer, because there are different circuits for each memory and segment registers are not normally used, but rather the memory is segregated and access to each type of memory depends on the processor's instructions..

Although in embedded systems with Von Neumann architecture the memory is segregated, and there are differences with respect to the traditional definition of this architecture; the buses to access both types of memory are the same, only the data bus, the address bus, and the control bus leave the processor. As a conclusion, the architecture has not been altered, because the way in which the memory is connected to the processor follows the same principle defined in the basic architecture.

Some families of microcontrollers such as the Intel 8051 and the Z80 implement this type of architecture, mainly because it was the one used when the first microcontrollers appeared.

Harvard Architecture

The other variant is the Harvard architecture, and par excellence the one used in supercomputers, microcontrollers, and embedded systems in general. In this case, in addition to memory, the processor has segregated buses, so that each type of memory has a data bus, an address bus, and a control bus.

The fundamental advantage of this architecture is that it allows the size of the buses to be adapted to the characteristics of each type of memory; In addition, the processor can access each of them simultaneously, which translates into a significant increase in processing speed. Typically systems with this architecture can be twice as fast as similar systems with von Neumann architecture.

The downside is that it consumes a lot of processor I/O lines; so in systems where the processor is located in its own package, it is only used in supercomputers. However, in microcontrollers and other embedded systems, where usually the data and program memory share the same package as the processor, this drawback is no longer a serious problem and that is why we find the Harvard architecture in most microcontrollers..

That is why it is important to remember that a microcontroller can be configured in different ways, as long as the memory size that it requires for its correct operation is respected.

Processor in detail

In the 1970s, digital electronics was not sufficiently developed, but within electronics it was already an established specialty. Computers back then were designed to do some very simple operations, and if you wanted these machines to be able to do different things, you needed to make some pretty significant changes to the hardware.

In the early 1970s, a Japanese company commissioned a young American company to develop circuitry to produce a low-cost calculator. Intel devoted himself fully to the task and among the commissioned circuits developed a very special one, something not created to date: the first integrated microprocessor.

The Intel 4004 was released in 1971, it is a complex synchronous digital machine, like any other synchronous sequential logic circuit. However, the advantage of this component is that it internally houses a set of digital circuits that can perform common operations for calculation and data processing, but from a different point of view: its inputs are a series of well-defined codes, which allow operations of a specific nature whose result is determined by the type of operation and the operands involved.

Looked at like this, there is nothing special about a microprocessor; The wonder is that the right combination of input codes, their sequential execution, being able to jump backwards or forwards in the sequence of codes based on logical decisions or specific commands, allows the machine to perform a large number of complex operations., not contemplated in the simple basic codes.

Today we are used to systems with microprocessors, but in the distant 1971 this was a slightly different and even scandalous way of thinking, to the point that Busicom, the company that ordered the chips from Intel was not interested in the invention, so Intel marketed it to others who showed interest; the rest is history: an unprecedented revolution in the technological advancement of humanity.

It is logical to think that the invention of the integrated microprocessor was not a divine revelation for its creators, but that it was based on the advances, existing up to now, in the field of digital electronics and computing theories. But without a doubt, it was the straw that broke the camel's cup of the scientific-technical revolution, because it allowed the development of unexpected applications or accelerated some already underway.

Now we will begin to see how a processor is made, it will not be a very detailed explanation because since its invention it has undergone important revolutions of its own, but there are basic aspects that have not changed and that constitute the basis of any microprocessor. In Figure 'Schematic of a microcontroller' we can see the typical structure of a microprocessor, with its fundamental components, of course no real processor fits exactly to this structure, but even so it allows us to know each of its basic elements and their interrelationships.

Logs

They are a very small memory space but necessary for any microprocessor, from here the data is taken for various operations that must be carried out by the rest of the processor circuits. The registers serve to store the results of the execution of instructions, to load data from the external memory or to store it in it.

Although the importance of logs seems trivial, it is not at all. In fact, a part of the registers, the one destined to the data, is the one that determines one of the most important parameters of any microprocessor. When we hear that a processor is 4, 8, 16, 32 or 64 bits, we are referring to processors that carry out their operations with data records of that size, and of course, this determines many of the potentialities of these machines.

The greater the number of bits in the data registers of the processor, the greater its benefits, in terms of computing power and execution speed, since this parameter determines the power that can be incorporated into the rest of the components For example, it doesn't make sense to have a 16-bit ALU on an 8-bit processor.

A 16-bit processor, on the other hand, can do a 16-bit addition in a single machine cycle, while an 8-bit processor must execute several instructions before getting the result, even though both processors have the same execution speed for your instructions. The 16-bit processor will be faster because it can do the same kind of tasks as an 8-bit one, in less time.

Control unit

This unit is one of the most important in the processor, it contains the necessary logic for the decoding and execution of the instructions, the control of the registers, the ALU, the buses and whatever else you want to put in the processor.

The control unit is one of the fundamental elements that determine the performance of the processor, since its type and structure determine parameters such as the type of instruction set, execution speed, machine cycle time, type of buses that the system can have, interrupt handling and a good number of other things that in any processor go to this block.

Of course, control units are the most complex element of a processor and are usually divided into smaller units working together. The control unit groups components such as the decoding unit, execution unit, cache memory controllers, bus controllers, interrupt controller, pipelines, among other elements, always depending on the type of processor.

Arithmetic-Logic Unit (ALU)

Since processors are circuits that basically do logical and mathematical operations, a complete unit is dedicated to this process, with some independence. This is where the addition, subtraction, and logical operations typical of Boolean algebra are performed.

Currently this type of units has evolved a lot and the most modern processors have several ALUs, specialized in carrying out complex operations such as floating point operations. In fact, in many cases they have changed their name to "math coprocessor", although this is a term that arose to name a special type of processor that connects directly to the more traditional processor.

Its impact on processor performance is also important because, depending on its power, more or less complex tasks can be done in very short times, such as floating point calculations.

Buses

They are the means of communication used by the different components of the processor to exchange information with each other, eventually the buses or a part of them will be reflected in the pins of the processor package.

In the case of microcontrollers, it is not common for the buses to be reflected in the package of the circuit, since these are basically destined to the I/O of general purpose and peripherals of the system.

There are three types of buses:

  • Address: It is used to select the device with which you want to work or in the case of memories, select the data you want to read or write.
  • Data: It is used to move data between devices hardware (entry and exit).
  • Control: It is used to manage different reading writing processes and control the operation of system devices.

Instruction Set

Although it does not appear in the schematic, we could not leave the instruction set or repertoire out of the explanation, because this element determines what the processor can do.

It defines the basic operations that the processor can perform, which when combined and organized form what we know as software. The set of instructions have been like the letters of the alphabet, the basic element of language, which, properly organized, allow you to write words, sentences and any program you can think of.

There are two basic types of instruction sets, which determine the architecture of the processor: CISC and RISC.

CISC, from English Complex Instruction Set Computing, complex instruction set computer. CISC microprocessors have a set of instructions that is characterized by being very broad and that allow complex operations to be carried out between operands located in memory or in internal registers. This type of repertoire makes parallelism between instructions difficult, so today most high-performance CISC systems convert complex instructions into several simple RISC-type instructions, often called microinstructions.

Within CISC microcontrollers we can find the popular Intel 8051 and Z80 family, although there are currently CISC-RISC versions of these microcontrollers, which aim to take advantage of RISC processors while maintaining backwards compatibility with CISC-type instructions.

RISC, from English Reduced Instruction Set Computer, Computer with Reduced Instruction Set. It focuses on obtaining processors with the following fundamental characteristics:

  • Fixed size instructions.
  • Few instructions.
  • Only load and storage instructions access data memory.
  • Relatively high number of general purpose records.

One of the most noteworthy characteristics of this type of processor is that they enable parallelism in execution, and reduce memory accesses. That is why the most modern processors, traditionally based on CISC architectures, implement CISC to RISC instruction translation mechanisms, to take advantage of this type of processor.

The processors of PIC microcontrollers are of the RISC type.

Memory

Previously it has been seen that the memory in microcontrollers must be located within the same package, this is the case most of the time, because the fundamental idea is to keep the bulk of the system circuitry within a single integrated chip.

In microcontrollers memory is not abundant, here you will not find Gigabytes of memory like in personal computers. Typically the program memory will not exceed 16 K-locations of non-volatile memory (flash or eprom) to contain the programs.

RAM memory is used to store temporary information that will be used by the processor to perform calculations or other types of logical operations. In the address space of RAM memory, the work registers of the processor and the configuration and work registers of the different microcontroller peripherals are also located. That is why in most cases, even if there is an address space of a certain size, the amount of RAM available to the programmer to store its data is less than the amount that the processor can address.

The type of memory used in the RAM memories of microcontrollers is SRAM, which avoids having to implement refreshing systems as in the case of personal computers, which use a large amount of memory, typically some DRAM technology. Although SRAM is more expensive than DRAM, it is the right type for microcontrollers because microcontrollers have small amounts of RAM.

In the case of program memory, different technologies are used, and the use of one or the other depends on the characteristics of the application to be developed. The five existing technologies that are or have been most widely used are described below:

  • Memory ROM (Read-Only Memorymask. In this case the program is not “recorded” but the microcontroller is manufactured with the program, it is a process similar to the production of commercial CDs by mastering. The initial cost of producing a circuit of this type is high, because the design and production of the mask is a costly process, however, when several thousand or even hundreds of thousands of microcontrollers are needed for a given application, such as some appliance, the initial cost of production of the mask and the production of the circuit is distributed among all circuits of the series, and the final cost of this is much lower than that of its similar memory.
  • PROM memory (Programmable Read-Only Memory) also known as OTP (One Time Programmable).
Microcontrollers with OTP memory can be programmed once, with some type of programmer. They are used in systems where the program does not require future updates and for relatively small series, where the mask variant is very expensive, also for systems that require data serialization, stored as constants in the program memory.
  • EPROM memory (Erasable Programmable Read Only Memory). Microcontrollers with this type of memory are very easy to identify because their encapsulate is ceramic and carry on a window of glass from which you can see the silicon oblea of the microcontroller.
They are manufactured thus because the EPROM memory is reprogrammable, but it must be erased before, and for this it must be exposed to an ultraviolet light source, the recording process is similar to that used for OTP memories.
With less expensive and more flexible technologies appearing, such as EEPROM and FLASH memories, this kind of memory has fallen into disuse, they were used in systems that require program updates and for development and start-up processes.
  • EEPROM (Electrical Erasable Programmable Read Only Memory). They were the natural substitute for EPROM memories, the fundamental difference is that they can be deleted electrically, so the quartz glass window and ceramic encapsulates are not necessary.
By lowering the costs of encapsulates, microcontrollers with this kind of memory became cheaper and comfortable to work than their EPROM equivalents.
Another notable feature of this type of microcontroller is that it was in them where programming systems began to be used in the system that avoid having to remove the microcontroller from the card that hosts it to update the program.
  • Flash memory. In the field of reprogrammable memories for microcontrollers, they are the latest technological advance in large-scale use, and have replaced microcontrollers with EEPROM memory.
The advantages of flash memories are added to their high density with respect to their predecessors, thus increasing the amount of program memory at a very low cost. They can also be programmed with the same power pressures of the microcontroller, reading access and programming speed is higher, lower production costs, among others.

The most common thing is to find that the program and data memory is located all inside the microcontroller, in fact, currently there are few microcontrollers that allow program memory to be connected outside the package. The reasons for these "limitations" are given because the fundamental objective is to obtain the greatest possible integration and connecting external memories consumes I/O lines, which are one of the most precious resources of microcontrollers.

Despite the above, there are families such as the Intel 8051 whose microcontrollers have the ability to be expanded in a wide range of configurations for the use of external program memory. In the case of PICs, these possibilities are limited only to some high-end microcontrollers, Figure 5 shows some of the configurations for program memory that we can find in microcontrollers. Configuration (a) is typical and we can find it in almost 100% of microcontrollers. Configuration (b) is rare and is usually achieved by configuring the microcontroller to sacrifice internal program memory, however the Intel 8031 is a microcontroller with no internal program memory. Configuration (c) is commonly found on microcontrollers that have the ability to expand their program memory like some high-end PICs.

When it is necessary to increase the amount of data memory, the most frequent thing is to place external memory devices in the form of peripherals, in this way RAM, FLASH memories or even hard drives such as those of personal computers can be used, while that for calculations and other operations that require temporary data storage, the internal RAM of the microcontroller is used. This way of expanding the data memory is determined, in most cases, by the type of instruction set of the processor and because it allows a large number of different configurations, in addition to the consequent savings in I/O lines that are achieved. with the use of memories with serial communication buses.

Interrupts

Interrupts are essentially subroutine calls generated by physical devices, as opposed to normal subroutines in a running program. Since the subroutine jump is not part of the scheduled thread or sequence of execution, the controller saves the state of the processor on the memory stack and goes into executing a special code called an "interrupt handler" that attends to the specific peripheral that generated the interrupt. At the end of the routine, a special instruction tells the processor to end attention to the interrupt. At this time the controller restores the previous state, and the program that was running before the interruption continues as if nothing had happened. Interrupt handling routines should be as short as possible for satisfactory system performance, because normally when one interrupt is handled, all other interrupts are waiting.

Imagine that you are expecting a visit from a friend, whom we will call John. You and Juan have agreed that when he gets home he will wait patiently for you to open the door. Juan shouldn't knock on the door because someone in the house is sleeping and he doesn't want to be woken up.

Now you have decided to read a book while you wait for Juan to get home, and to check if he has arrived, every so often he stops reading, marks the page where he left off, gets up and goes to the open the door and check if Juan has arrived, if he is not at the door yet, he will wait a few minutes, close the door and return to his reading for some time.

As you will see, this is an inefficient method to wait for Juan because it requires him to stop reading from time to time and go to the door to check if he has arrived, plus he must wait a while if he still hasn't arrived. And as if that weren't enough, imagine that Juan never shows up because he had a problem, he had to cancel the appointment and couldn't let him know on time, or worse, that Juan arrived at the door an instant after you closed it. Juan, respecting the agreement, waits for a while, but he gets tired of waiting for them to open and decides to leave because he believes that you are no longer at home or cannot take care of you. We will call this method of attending to the arrival of Juan a survey.

Now let's look at another method. On this occasion, he simply lies down on the living room sofa and begins to read his book. When Juan arrives, he must ring the doorbell and wait a few moments for them to attend to him. When you hear the bell ring, you stop reading, mark the page where you left off, and go to the door to attend to the person who rings the bell. Once John or the person who rang the bell leaves, you return to his seat and pick up right where he left off. The latter is a more efficient method than the former because it leaves you more time to read and eliminates some inconveniences like John never arriving or leaving before you open the door. It is, in principle, a simple but very effective and efficient method, we will call it attention by interruption.

The first of them, the survey, is an effective method, but inefficient because it requires constant and often unnecessary readings of the state of the process that we want to address. However, it is widely used in microcontroller programming because it is easy to learn, code implementation with this method is less complex, and it does not require special hardware to carry it out. On the other hand, the survey has many deficiencies that frequently force the designer to move towards other horizons.

The world is full of situations; of which we cannot determine when, how or why they occur, in most cases the only thing we can do is find out that a certain situation, associated with a process, has occurred. To do this, we select some condition or group of conditions that indicate that the process that interests us must be attended to, this phenomenon, in which the conditions that we are interested in knowing occur, we will call it an event. In the second example we see that to attend to Juan, he must ring the bell, therefore, the arrival of Juan is the process that we must attend to and the sound of the bell is the event that indicates that Juan has arrived.

The method of attention to processes by interruption, seen from the point of view of the example that I used to show it, is simpler than that of the survey, but it is not true, the method is complicated because it requires the microprocessor to incorporate additional circuits to recording the events that tell you to attend to the associated process and understanding these circuits and their dynamics is not an easy task.

The circuits for handling interrupts and all the tasks that the processor must perform to handle the process that interrupts it are quite complex and require a different view of our world than we are used to.

Human beings are not aware of interruptions, in our organism there are mechanisms that constantly interrupt us, for this we have our sensory system, but we are not aware of the interruption process, although we are aware of the attention to interruptions. That is because we incorporate mechanisms that quickly take us out of the task we are doing to deal with a situation that cannot or should not wait a long time. Well, that is the same idea that is incorporated into microprocessors to attend to processes that cannot wait or that we do not know when they should be attended to because it depends on certain conditions.

Things get complicated in the sequence of actions to be carried out from the moment the interrupt process is triggered, until the program that attends it is executed, and in the sequence of actions after the attention. Think about how many things your body should do when faced with an interruption. Let's use the second example to deal with Juan's arrival. Think about how many things your brain does behind your conscious awareness, from the moment the doorbell rings until you are ready (aware that John has probably arrived) to open the door, and all that your brain must work to resume reading after Juan has left. We do all of this, except opening the door and attending to Juan, “unconsciously” because we have dedicated systems in our body for this, but in the world of microcontrollers we must know all these details to be able to use the interruption mechanisms.

Interrupt handling processes have the advantage that they are implemented by hardware located in the processor, so it is a quick method of making the processor run a special program to handle events that cannot wait for mechanisms slow as the survey.

In general terms, an interrupt process and its attention by the processor, has the following sequence of actions:

  1. In the real world the event is produced for which we want the processor to run a special program, this process has the characteristic that it cannot wait long before being attended or we do not know at what time it should be attended.
  2. The circuit responsible for detecting the event's occurrence is activated, and as a result, the processor's interruption input is activated.
  3. The control unit detects that there has been an interruption and “lead” a flag to record this situation; in this way if the conditions that caused the event disappear and the circuit responsible for detecting it deactivates the processor’s interruption entry, it will occur in any way, because it has been registered.
  4. The executing unit ends with the current instruction and just before the start of the next check that an interruption has been recorded
  5. A process is triggered to save the current status of the running program and jump to a special program memory address, where there is the first instruction of the interruption care subroutine.
  6. The interruption care code is executed, this is the “conscious” part of the whole process because it is where the actions of the attention to the interruption are carried out and the programmer plays its role.
  7. When the break-in subroutine executes the return instruction, the process of restoring the processor to the state in which it was before the attention to the interruption is triggered.

As we can see, the interrupt mechanism is quite complicated, however it has two advantages that force its implementation: speed and its ability to be asynchronous. Both together allow us to take full advantage of the work capabilities of our processor.

Interrupt mechanisms are not only used to handle events linked to processes that require immediate attention, but are also used to handle events from asynchronous processes.

Interrupts are so powerful that they allow the processor to act like it's multitasking when it's actually doing the same old routine, executing instructions one after the other.

Peripherals

When we look at the basic organization of a microcontroller, we point out that a set of peripherals are located within it. Next we will describe some of the peripherals that we will most frequently find in microcontrollers.

General purpose inputs and outputs

Also known as I/O ports, generally grouped into 8-bit-long ports, they allow data to be read from the outside or written to from inside the microcontroller, the usual destination is to work with simple devices such as relays, LEDs, or whatever else the programmer comes up with.

Some I/O ports have special features that allow them to handle outputs with certain current requirements, or incorporate special interrupt mechanisms for the processor.

Typically any I/O pin can be considered general-purpose I/O, but since microcontrollers can't have infinitely many pins, or even as many pins as we want, general-purpose I/Os share pins with others. peripherals. To use a pin with any of the characteristics assigned to it, we must configure it through the registers assigned to them.

Timers and counters

They are synchronous circuits for counting the pulses that come into their power to get the clock input. If the source of a large count is the microcontroller's internal oscillator, it is common for them not to have an associated pin, and in this case they work as timers. On the other hand, when the counting source is external, then they have an associated pin configured as an input, this is the counter mode.

Timers are one of the most common peripherals in microcontrollers and are used for many tasks, such as frequency measurement, clock implementation, working in conjunction with other peripherals that require a stable time base. among other functionalities. Often a typical microcontroller incorporates more than one timer/counter and some even have arrays of counters. As we will see later, this peripheral is an almost essential element and it is common for them to have some interruption associated with them. Typical count register sizes are 8 and 16 bits, and you may find devices that only have timers of one size or more often with both count register types.

Analog/Digital Converter

As it is very common to work with analog signals, they must be converted to digital and therefore many microcontrollers incorporate an analog-digital converter, which is used to take data from several different inputs that are selected by a multiplexer.

The most frequent resolutions are 8 and 10 bits, which are sufficient for simple applications. For control and instrumentation applications, 12bit, 16bit and 24bit resolutions are available. It is also possible to connect an external converter, if necessary

Communication ports

Serial port

This peripheral is present in almost any microcontroller, usually in the form of a UART (Universal Asynchronous Receiver Transmitter) or USART (Universal Synchronous Asynchronous Receiver Transmitter) depending on whether they allow or not the synchronous mode of communication.

The common destination of this peripheral is communication with another microcontroller or with a PC and in most cases external circuitry has to be added to complete the communication interface. The most common way to complete the serial port is to communicate with a PC through the EIA-232 interface (better known as RS-232), which is why many people refer to the UART or USART as RS-232 serial port, but this constitutes an error, since this peripheral can be used to interconnect devices through other communication standards. In industrial applications RS-485 is preferably used for its superior range in distance, speed and resistance to noise.

SPI

This type of peripheral is used to communicate the microcontroller with other microcontrollers or with external peripherals connected to it, through a very simple interface. There is only one controller node that allows any transaction to be started, which is a disadvantage in complex systems, but its simplicity allows galvanic isolation directly by means of optocouplers.

I2C

Performs the same functions as SPI, but requires fewer communication signals and any node can initiate a transaction. It is widely used to connect the graphics cards of personal computers with the monitors, so that the latter report their benefits and allow the self-configuration of the video system.

USB

Microcontrollers are what have allowed the existence of this communication system. It is a system that works by polling (monitoring) a set of intelligent peripherals by a master, which is normally a personal computer. Each smart mode is inevitably governed by a microcontroller.

Ethernet

It is the most widespread system in the world for wired local area networks. The most powerful 32-bit microcontrollers are used to implement peripherals powerful enough that they can be directly accessed over the network. Many small business home routers are built around a microcontroller that acts as the brain of the system.

Can

This protocol is of the CSMA/CD type with tolerance to high voltage levels in common mode and oriented to real time. This protocol is the most important standard in the automotive industry (OBD). It is also used as the physical layer of the "field bus" for industrial control.

Other communication ports

There are a huge number of other buses available for the automotive industry (linbus) or audiovisual media such as i2s, IEEE 1394. The user will come across them when working in some specialized area.

Comparators

They are analog circuits based on operational amplifiers that have the characteristic of comparing two analog signals and outputting the logic levels '0' or '1' depending on the result of the comparison. It is a very useful peripheral to detect changes in input signals that we are only interested in knowing when it is in a certain voltage range.

Pulse Width Modulator

PWM (Pulse Width Modulator) are very useful peripherals, especially for motor control, however there is a group of applications that can be carried out with this peripheral, among which we can cite: DC/AC inversion for UPS, digital analog D/A conversion, regulated light control (dimming) among others.

Non-volatile data memory

Many microcontrollers have incorporated these types of memory as one more peripheral, for storing configuration data or processes that are controlled. This memory is independent of the RAM-type data memory or the program memory, in which the program code to be executed by the microcontroller processor is stored.

Many PIC microcontrollers include this type of memory, typically in the form of EEPROM memory, some of them even allow part of the program memory to be used as non-volatile data memory, so the processor has the ability to write in the program memory as if it were just another peripheral.

Families of microcontrollers

The most common microcontrollers in use are:

Company 8 bits 16 bits 32 bits
Atmel AVR (mega and tiny), 89Sxxx family similar 8051 SAM7 (ARM7TDMI), SAM3 (ARM Cortex-M3), SAM9 (ARM926), AVR32
Freescale
(before Motorola)
68HC05, 68HC08, 68HC11, HCS08 68HC12, 68HCS12, 68HCSX12, 68HC16 683xx, PowerPC, ColdFire
Holtek HT8
Intel MCS-48 (Family 8048)
MCS51 (Family 8051)
8xC251
MCS96, MXS296 x
National Semiconductor COP8 x x
Microchip Family 10f2xx Family 12Cxx Family 12Fxx, 16Cxx and 16Fxx 18Cxx and 18Fxx PIC24F, PIC24H and dsPIC30FXX, dsPIC33F with integrated dsp engine PIC32
NXP Semiconductors
(before Philips)
80C51 XA Cortex-M3, Cortex-M0, ARM7, ARM9
Renesas
(formerly Hitachi, Mitsubishi and NEC)
78K, H8 H8S, 78K0R, R8C, R32C/M32C/M16C RX, V850, SuperH, SH-Mobile, H8SX
STMicroelectronics ST 62, ST 7 STM32 (ARM7)
Texas Instruments TMS370 MSP430 C2000, Cortex-M3 (ARM), TMS570 (ARM)
Zilog Z8, Z86E02

Note: Some microcontroller architectures are available from so many vendors and in so many varieties that they could, quite correctly, have their own category. Among them we find, mainly, the variants of Intel 8051 and Z80.

Contenido relacionado

Duralumin

Duralumin is an alloy of aluminum with copper, manganese, magnesium and silicon. They belong to the family of aluminum-copper alloys...

DR-DOS

DR-DOS is an MS-DOS-compatible operating system for IBM PC-compatible personal computers. It was originally developed by Gary Kildall's Digital Research and...

Darwin (operating system)

Darwin is an open source Unix-like operating system, first released by Apple Inc. in the year 2000. It consists of code developed by Apple, as well as code...
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save