Introduction to Microcontrollers: 2 of 6
We continue with our presentation of basic technical concepts that must be mastered by all students of embedded systems engineering. In our previous session, we looked at some basic microcontroller concepts. In this session, we look at some of the hardware (peripheral circuitry) required to run a microprocessor. In our next session, we will see how to put a real microcontroller to work.
"Generator" Power Circuitry
In our last session we looked at the basic structure and operation of a microcontroller (MCU). Now let's look at some of the hardware (peripheral circuitry) required to support the microprocessor. In particular, we will look at some hardware used in the Renesas RL78 Family (RL78/G14), one of the new-generation general-purpose MCUs.
An MCU, like any of its various components introduced in Digital Circuits, needs a power supply to drive it. So it must be connected to an outside battery or other suitable power source. Figure 1 shows the pin arrangement on a 64-pin RL78 Family (RL78/G14) chip. Pins 13/14 (VSS/EVSS0) and 15/16 (VDD/EVDD0) are the power pins, which connect as follows:
- Pins 13 (VSS) and 14 (EVSS0) to GND.
- Pins 15 (VDD) and 16 (EVDD0) to the positive terminal of the power supply.
The datasheet (hardware manual) for the RL78 Family (RL78/G14) indicates that the power voltage (VDD) must be between 1.6 and 5.5 V. This means that the MCU is guaranteed to run when supplied with any voltage within this range. This voltage range is referred to as the operating voltage, or, in some hardware manuals, as the recommended operating voltage.
Figure 2 shows an example of an actual power-connection configuration of a 64-pin RL78 Family (RL78/G14) MCU.
- Pin 15 connects to bypass capacitor C1. This bypass prevents malfunctions that might otherwise occur when a current spike causes the voltage to drop. A typical bypass capacitor is a ceramic capacitor with capacitance between 0.01 and 0.1 µF.
- The power-supply voltage is stepped down by an internal regulator to the voltage used to drive the MCU's internal circuitry: that is, to either 1.8 V or 2.1 V. The regulator itself is stabilized by another capacitor, C2, at pin 12.
"Conductor" Oscillators
As we saw in our third session on digital circuitry basics, sequential circuits operate in sync with the rising or falling edge of a clock (CK) signal. MCUs consist of sequential circuits, and so they require a CK signal. This external clock signal is provided by an external oscillator connected to the MCU.
Figure 3 shows an example of an external oscillator connected to an RL78 Family (RL78/G14) MCU. Specifically, a crystal oscillator is connected to pins X1 and X2. The MCU includes two internal clock oscillators that work in conjunction with the external clock signal.
- The main clock drives the CPU.
- The sub-clock is typically used with peripheral circuits or as a real-time clock.
Because the RL78 Family (RL78/G14) uses a highly precise on-chip oscillator (accurate to within 1%) to drive its robust set of peripheral circuitry, it can operate without need of an external clock. MCUs driven by internal clocks are less expensive to design.
Even where an on-chip oscillator is present, however, an external crystal oscillator may be used in cases where it is necessary to achieve better precision and lower temperature-induced variation; for example, in MCUs used to control watches and so on.
"Alarm Clock" Reset Circuit
It takes a short time after MCU power-on for the internal circuitry to stabilize. During this interval, the CPU cannot be expected to perform normally. This problem is resolved by applying a reset signal to the reset pin on the MCU. Setting the signal to active (LOW) causes the MCU to reset.
The signal into the reset input pin must remain LOW until the power-supply and clock signals stabilize; this pin must connect internally to that part of the circuitry that needs time to stabilize. Figure 4 shows how this can be accomplished using a power-on reset circuit (an RC circuit).
The incoming power voltage moves through this circuit's resistor, causing some of the initial current to flow into the capacitor. As a result, the voltage rise into the reset pin is gradual. The reset condition is cleared when the rising voltage reaches a predetermined level.
As you can see in the above figure, there is also a manual reset circuit located next to the power-on reset circuit. The user can reset the MCU at any time by throwing the manual circuit's reset switch.
On a general-purpose MCU, the reset signal must stay LOW for a predetermined interval. This interval is specified in the MCU's hardware manual or datasheet. The values for the power-on reset circuit's resistor (R) and capacitor (C) must be selected accordingly.
Conveniently, the Renesas RL78 Family (RL78/G14) uses its own internal power-on reset circuitry to handle its resets. The MCU automatically clears the reset when the power input rises to the MCU's operating voltage.
CPU Reset
A reset operation causes the CPU to reinitialize the value of its program counter. (The program counter is the register that stores the address of the next instruction that the CPU will execute.) Upon reinitializing, the program counter (PC) will hold the start address of the first program to be run. Either of two methods may be used for getting this first address: either static start addressing or vector reset addressing.
- In static start addressing mode, the MCU always starts program execution at the same fixed address. The address itself is different for each MCU model. If the PC value is 0, for example, then program execution will start with the instruction at address 0.
- In vector reset mode, the CPU starts by reading a pointer value stored at a fixed address (called the reset vector) in ROM. Specifically, the CPU gets and decodes the pointer value, then places the resulting value into the program counter. This may seem more complicated than the static method described above; an important advantage, however, is that it allows the initial program address to be freely changed.
* This article was revised on March 30, 2015.
In our third installment of this MCU introduction, we will look at the MCU development environment and try out some real MCU operations. As always, we look forward to your continued participation.