Выбрать главу

1.3.11 LCD Drivers

LCD drivers enable a microcontroller to be connected to an external LCD display directly. These drivers are not common since most of the functions they provide can be implemented in software. For example, the PIC18F6490 microcontroller has a built-in LCD driver module.

1.3.12 Analog Comparator

Analog comparators are used where two analog voltages need to be compared. Although these circuits are implemented in most high-end PIC microcontrollers, they are not common in other microcontrollers. The PIC18F series of microcontrollers has built-in analog comparator modules.

1.3.13 Real-time Clock

A real-time clock enables a microcontroller to receive absolute date and time information continuously. Built-in real-time clocks are not common in most microcontrollers, since the same function can easily be implemented by either a dedicated real-time clock chip or a program written for this purpose.

1.3.14 Sleep Mode

Some microcontrollers (e.g., PICs) offer built-in sleep modes, where executing this instruction stops the internal oscillator and reduces power consumption to an extremely low level. The sleep mode’s main purpose is to conserve battery power when the microcontroller is not doing anything useful. The microcontroller is usually woken up from sleep mode by an external reset or a watchdog time-out.

1.3.15 Power-on Reset

Some microcontrollers (e.g., PICs) have built-in power-on reset circuits which keep the microcontroller in the reset state until all the internal circuitry has been initialized. This feature is very useful, as it starts the microcontroller from a known state on power-up. An external reset can also be provided, where the microcontroller is reset when an external button is pressed.

1.3.16 Low-Power Operation

Low-power operation is especially important in portable applications where microcontroller-based equipment is operated from batteries. Some microcontrollers (e.g., PICs) can operate with less than 2mA with a 5V supply, and around 15mA at a 3V supply. Other microcontrollers, especially microprocessor-based systems with several chips, may consume several hundred milliamperes or even more.

1.3.17 Current Sink/Source Capability

Current sink/source capability is important if the microcontroller is to be connected to an external device that might draw a large amount of current to operate. PIC microcontrollers can source and sink 25mA of current from each output port pin. This current is usually sufficient to drive LEDs, small lamps, buzzers, small relays, etc. The current capability can be increased by connecting external transistor switching circuits or relays to the output port pins.

1.3.18 USB Interface

USB is currently a very popular computer interface specification used to connect various peripheral devices to computers and microcontrollers. Some PIC microcontrollers provide built-in USB modules. The PIC18F2x50, for example, has built-in USB interface capabilities.

1.3.19 Motor Control Interface

Some PIC microcontrollers, for example the PIC18F2x31, provide motor control interface capability.

1.3.20 CAN Interface

CAN bus is a very popular bus system used mainly in automation applications. Some PIC18F-series microcontrollers (e.g., the PIC18F4680) provide CAN interface capability.

1.3.21 Ethernet Interface

Some PIC microcontrollers (e.g., the PIC18F97J60) provide Ethernet interface capabilities and thus are easily used in network-based applications.

1.3.22 ZigBee Interface

ZigBee, an interface similar to Bluetooth, is used in low-cost wireless home automation applications. Some PIC18F-series microcontrollers provide ZigBee interface capabilities, making the design of such wireless systems very easy.

1.4 Microcontroller Architectures

Two types of architectures are conventional in microcontrollers (see Figure 1.4). Von Neumann architecture, used by a large percentage of microcontrollers, places all memory space on the same bus; instruction and data also use the same bus.

Figure 1.4: Von Neumann and Harvard architectures

In Harvard architecture (used by PIC microcontrollers), code and data are on separate buses, which allows them to be fetched simultaneously, resulting in an improved performance.

1.4.1 RISC and CISC

RISC (reduced instruction set computer) and CISC (complex instruction computer) refer to the instruction set of a microcontroller. In an 8-bit RISC microcontroller, data is 8 bits wide but the instruction words are more than 8 bits wide (usually 12, 14, or 16 bits) and the instructions occupy one word in the program memory. Thus the instructions are fetched and executed in one cycle, which improves performance.

In a CISC microcontroller, both data and instructions are 8 bits wide. CISC microcontrollers usually have over two hundred instructions. Data and code are on the same bus and cannot be fetched simultaneously.

1.5 Number Systems

To use a microprocessor or microcontroller efficiently requires a working knowledge of binary, decimal, and hexadecimal numbering systems. This section provides background information about these numbering systems for readers who are unfamiliar with them or do not know how to convert from one number system to another. Number systems are classified according to their bases. The numbering system used in everyday life is base 10, or the decimal number system. The numbering system most commonly used in microprocessor and microcontroller applications is base 16, or hexadecimal. Base 2, or binary, and base 8, or octal, number systems are also used.

1.5.1 Decimal Number System

The numbers in the decimal number system, of course, are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The subscript 10 indicates that a number is in decimal format. For example, the decimal number 235 is shown as 23510.

In general, a decimal number is represented as follows:

an × 10n + an–1 × 10n–1 + an-2 × 10n-2 + ……… + a0 × 100

For example, decimal number 82510 can be shown as:

82510 = 8 × 102 + 2 × 101 + 5 × 100

Similarly, decimal number 2610 can be shown as:

2610 = 2 × 101 + 6 × 100

or

335910 = 3 × 103 + 3 × 102 + 5 × 101 + 9 × 100

1.5.2 Binary Number System

The binary number system consists of two numbers: 0 and 1. A subscript 2 indicates that a number is in binary format. For example, the binary number 1011 would be 10112. In general, a binary number is represented as follows: