Microcontrollers
eBook - ePub

Microcontrollers

Fundamentals and Applications with PIC

Fernando E. Valdes-Perez, Ramon Pallas-Areny

  1. 300 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Microcontrollers

Fundamentals and Applications with PIC

Fernando E. Valdes-Perez, Ramon Pallas-Areny

Book details
Book preview
Table of contents
Citations

About This Book

Microcontrollers exist in a wide variety of models with varying structures and numerous application opportunities. Despite this diversity, it is possible to find consistencies in the architecture of most microcontrollers. Microcontrollers: Fundamentals and Applications with PIC focuses on these common elements to describe the fundamentals of microcontroller design and programming. Using clear, concise language and a top-bottom approach, the book describes the parts that make up a microcontroller, how they work, and how they interact with each other. It also explains how to program medium-end PICs using assembler language.

Examines analog as well as digital signals

This volume describes the structure and resources of general microcontrollers as well as PIC microcontrollers, with a special focus on medium-end devices. The authors discuss memory organization and structure, and the assembler language used for programming medium-end PIC microcontrollers. They also explore how microcontrollers can acquire, process, and generate digital signals, explaining available techniques to deal with parallel input or output, peripherals, resources for real-time use, interrupts, and the specific characteristics of serial data interfaces in PIC microcontrollers. Finally, the book describes the acquisition and generation of analog signals either using resources inside the chip or by connecting peripheral circuits.

Provides hands-on clarification

Using practical examples and applications to supplement each topic, this volume provides the tools to thoroughly grasp the architecture and programming of microcontrollers. It avoids overly specific details so readers are quickly led toward design implementation. After mastering the material in this text, they will understand how to efficiently use PIC microcontrollers in a design process.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Microcontrollers an online PDF/ePUB?
Yes, you can access Microcontrollers by Fernando E. Valdes-Perez, Ramon Pallas-Areny in PDF and/or ePUB format, as well as other popular books in Informatique & Ingénierie de l'informatique. We have over one million books available in our catalogue for you to explore.

Information

Publisher
CRC Press
Year
2017
ISBN
9781351834551

1

Introduction to Microcontrollers

This chapter studies the structure and resources found in typical microcontrollers. It starts by introducing the concept of a microcontroller and exploring the differences between microcontrollers and microprocessors. It continues with the description of the resources that are available in microcontrollers, focusing again on how they differ from the resources available in microprocessors. The chapter then describes the von Neumann and Harvard architectures as well as how the reduced instruction set computer (RISC) and complex instruction set computer (CISC) architectures differ in their instruction sets. It finishes by describing the most common microcontrollers and listing their manufacturers.

1.1 Microprocessors and Microcontrollers: Characterization

Figure 1.1 shows the block diagram of a generic microcomputer. It consists of three fundamental blocks: central processing unit (CPU), memory, and input/output (I/O) system. These blocks are interconnected by groups of electrical lines called buses. The buses that transport memory or I/O addresses are called address buses; the buses that transport data or instructions are called data buses; and the buses that transport control signals are called control buses.
The CPU is the brain of the microcomputer, being under control of the program stored in memory. The tasks of the CPU are to fetch the instructions stored in memory, interpret those instructions, and execute them. The CPU also includes the circuitry necessary to perform arithmetic and logic operations with binary data. This special circuitry is called the arithmetic and logic unit (ALU).
In a microcomputer, the CPU is its microprocessor, which is the integrated circuit that carries out the operations described above. A microcontroller can be considered as a microcomputer built on a single integrated circuit or chip. Historically, microcontrollers appeared after microprocessors and followed independent paths. Microprocessors are mainly found in personal computers and workstations, as these require strong computational power, and the ability to manage large sets of data and instructions at a high speed. A very important parameter for microprocessors is the size of their internal registers (8, 16, 32, or 64 bits), as this determines the number of bits that can be processed simultaneously.
Images
Figure 1.1 Generic block diagram of a microcomputer. Here, the CPU is the microprocessor.
On the other hand, microcontrollers are used in a large variety of applications. They can be found in the automotive industry, communication systems, electronic instrumentation, hospital equipment, industrial equipment and applications, household appliances, toys, and so forth. Microcontrollers have been designed to be used in applications in which they have to carry out a small number of tasks at the lowest possible economic cost. They do this by executing a program permanently stored in their memory, whereas the input/output ports of the microcontroller are used to interact with the outside world. Therefore, the microcontroller becomes part of the application; it is a controller embedded in the system. Complex applications can use several microcontrollers, each one of them focusing on a small group of tasks.
The following generic requirements are important for microcontrollers and designs using microcontrollers:
  1. Input/output resources. As opposed to microprocessors in which the emphasis is on computational power, microcontrollers put their emphasis on their input/output resources, such as the ability to handle interrupts, analog signals, number of different input and output lines, and so forth.
  2. Optimization of space. It is important to use the smallest possible footprint at a reasonable cost. Given that the number of pins in a chip depends on its packaging, the footprint can be optimized by having one pin able to perform several different functions.
  3. Using the most appropriate microcontroller for a given application. Microcontroller manufacturers have developed families of devices with the same instruction set but different hardware aspects, such as memory size, input/output devices, and so forth. This allows the designer to select the most appropriate device from a given family.
  4. Protection against failure. It is critical for safety to guarantee that the microcontroller is executing the correct program. If for any reason the program goes astray, the situation has to be immediately corrected. Microcontrollers have a watchdog timer (WDT) to ensure that the program is being executed correctly. Watchdog timers do not exist in personal computers.
  5. Low power consumption. Because batteries power many applications using microcontrollers, it is important to ensure the low power consumption of microcontrollers. Furthermore, the energy used when the microcontroller is not doing anything, for example, when it is waiting for an action from the user like a keyboard input, needs to be kept to a minimum. To do this, the microcontroller is set in sleeping state until it resumes the execution of the program.
  6. Protection of programs against copies. The program stored in memory needs to be protected against unauthorized reading. To do this, the microcontrollers incorporate protection mechanisms against copying.

1.2 Components of a Microcontroller

Microcontrollers combine the fundamental resources available in a microcomputer such as the CPU, memory, and I/O resources in a single chip. Figure 1.2 shows the block diagram for a generic microcontroller.
Microcontrollers have an oscillator to generate the signal necessary to synchronize all internal operations. Although this can be a basic RC (resistance capacitor) oscillator, a quartz crystal (XTAL) is normally used due to its high frequency stability. The frequency of the oscillator has a direct influence on the speed at which program instructions are executed.
Similar to microcomputers, the CPU is the brain of the microcontroller. The CPU fetches the program instructions from their locations in memory one by one, interprets or decodes them, and executes them. The CPU also includes the ALU circuits for binary arithmetic and logic operations.
The microcontroller’s CPU has different registers. Some of these registers are intended for general use, whereas others have a specific purpose. Specific purpose registers include: instruction register, accumulator, status register, program counter, data address register, and stack pointer.
Images
Figure 1.2 Basic block diagram of a microcontroller.
The instruction register (IR) stores the instruction that the CPU is executing. The programmer does not normally have access to the IR.
The accumulator (ACC) is a register associated with the arithmetic and logic operations that the ALU is carrying out. When executing any operation, one of the data needs to be in the ACC. The resulting value is also stored in the ACC. PIC microcontrollers do not have the ACC register. Instead, they have a working (W) register that is very similar to the ACC.
The status register (STATUS) contains the bits that show different characteristics related to the operations carried out by the ALU. These can be the sign of the resulting value (positive vs. negative), a flag to notify if the resulting value is zero, carry over, parity bits, and so forth.
The program counter (PC) is the CPU register where addresses of instructions are stored. Every time that the CPU looks for an instruction in the memory, the PC is increased, pointing to the following instruction. In an instant of time, the PC contains the address of the instruction that will be executed next. The control transfer instructions modify the value stored in the PC.
The data address register (DAR) stores data addresses from memory. This register plays a major role in indirect data addressing. Different types of microcontrollers use different specific names for the DAR. For example, PIC microcontrollers call this register the file select register (FSR).
The stack pointer (SP) stores data addresses in the stack. The stack and the SP register are studied in further detail in Chapter 4. PIC microcontrollers do not have an SP register.
The microcontroller memory stores both program instructions and data. Any microcontroller has two types of memory: random-access memory (RAM) and read-only memory (ROM). RAM can be read and written. RAM is volatile memory, meaning that its data is lost when it is not powered. On the other hand, although ROM can only be read, it is non-volatile. The different types of technologies used for ROM such as EPROM (erasable programmable read-only memory), EEPROM (electrical erasable programmable read-only memory), OTP (one-time programmable), and FLASH are described in detail in Chapter 3. Both RAM and ROM are “random access” memories, meaning that the time to access specific data does not depend on its stored location. This is opposed to sequential access memories in which the time needed to access a specific memory cell depends on the location of the last accessed cell.
ROM is used to permanently store the program for the microcontroller, whereas RAM is used to temporarily store the data that will be manipulated by the program. An increasing number of microcontrollers use non-volatile memory such as EEPROM to store some of the data that is changed only sporadically. The size of ROM is larger than the size of RAM for two main reasons: First, most applications require programs that manipulate a relatively small number of data. Second, RAM has a larger footprint compared to ROM, and therefore it is more expensive than ROM.
Being the vehicle to communicate with the outside world, the I/O resources are very important in microcontrollers. I/O resources consist of the serial and parallel ports, timers, and interruption managers. Some microcontrollers also incorporate analog input and output lines associated with analog-to-digital (A/D) and digital-to-analog (D/A) converters. The resources needed to ensure the regular operation of the microcontrollers such as the watchdog are also considered part of the I/O resources.
Parallel ports are normally structured in groups of up to eight lines of digital inputs and outputs. It is normally possible to manipulate each one of these lines individually. Serial ports can be of different technologies such as RS-232C (Recommended Standard 232, Revision C), I2C (interintegrated circuit), USB (universal serial bus), and Ethernet. In general, a microcontroller will have the largest possible number of I/O resources for the number of available pins in its integrated circuit package. To increase the performance, one physical pin can be connected to several internal blocks, and therefore that pin may carry out different functions depending on how the microcontroller has been configured.

1.2.1 The Watchdog

The watchdog timer (WDT) is a resource that can be found in most microcontrollers. As shown in Figure 1.3, the WDT consists of an oscillator and a binary counter of N bits. Although the oscillator can be the same oscillator used by the microcontroller, it is preferable to use an independent oscillator. The output of the counter is connected to the reset input for the microcontroller. The counting process can never be stopped, although the program being executed can periodically reset the counter to its initial value.
Images
Figure 1.3
Basic watchdog diagram. Its output is connected to the internal circuitry to generate the reset signal.
Every pulse at the output of the oscillator becomes an input to the counter....

Table of contents

Citation styles for Microcontrollers

APA 6 Citation

Valdes-Perez, F., & Pallas-Areny, R. (2017). Microcontrollers (1st ed.). CRC Press. Retrieved from https://www.perlego.com/book/1485349/microcontrollers-fundamentals-and-applications-with-pic-pdf (Original work published 2017)

Chicago Citation

Valdes-Perez, Fernando, and Ramon Pallas-Areny. (2017) 2017. Microcontrollers. 1st ed. CRC Press. https://www.perlego.com/book/1485349/microcontrollers-fundamentals-and-applications-with-pic-pdf.

Harvard Citation

Valdes-Perez, F. and Pallas-Areny, R. (2017) Microcontrollers. 1st edn. CRC Press. Available at: https://www.perlego.com/book/1485349/microcontrollers-fundamentals-and-applications-with-pic-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Valdes-Perez, Fernando, and Ramon Pallas-Areny. Microcontrollers. 1st ed. CRC Press, 2017. Web. 14 Oct. 2022.