Understanding the Fundamentals: Exploring Microprocessor, Microcontroller, and Programming Basics

Common computer organization

The Arithmetic Logic Unit (ALU) is a component designed to perform a range of operations, such as addition, shifting, AND, OR, and others, on specific on-chip registers. The Central Processing Unit (CPU) encompasses the control logic, relevant registers, and the arithmetic logic unit.

Computer buses

The address bus is responsible for conveying the address of a specific memory location or input/output (I/O) device.

Data bus: Transports data stored in memory (or an I/O device) to and from the CPU, or between memory and I/O devices.

Control bus: Comprises a set of control signals responsible for coordinating and synchronizing the entire system.

Block diagram of a typical CPU

CPU structure

The primary operations include:
– Transfer of data
– Arithmetic and logical operations
– Decision-making processes (instructional flow control)

The register array comprises a minimum of one accumulator, program counter, and stack pointer.

The control unit oversees all CPU operations, primarily directing the CPU through its fetch and execution phases.

Memory

In a computer system, memory functions to store both program instructions and data.

Main memory types

– Read-Only Memory (ROM):
– Pre-programmed permanently during manufacturing, incapable of alteration.

– Random-Access Memory (RAM):
– Memory that allows both reading and writing operations.

– Erasable Programmable ROM (EPROM):
– Nonvolatile memory written electrically but erased optically.

– Electrically Erasable ROM (EEPROM):
– Nonvolatile memory that can be both written and erased electrically.

Operation of the CPU

• Instruction Fetch Cycle:
– The CPU places the address of the instruction to be executed onto the address bus, sourced from the program counter (PC) managed by the control unit.
– Information necessary for reading the memory location is transmitted via the control bus, while the instruction from memory is received through the data bus and stored into the instruction register (IR).
– The program counter (PC) is updated to indicate the address of the next instruction.

• Instruction Execute Cycle:
– The instruction stored in the instruction register (IR) is decoded.
– The required data transfer and logical or arithmetic operations are carried out.
– The resulting data is written back to either a register, memory, or an I/O device.

• Common Operations Executed in ALU (Arithmetic Logic Unit) include:
– Addition and subtraction
– Logical operations such as AND, OR, XOR, and NOT
– Incrementing, decrementing, shifting, clearing, etc.

Microcomputer

– A microprocessor (µP) refers to a Central Processing Unit (CPU) integrated onto a single IC.
– The terms CPU, µP, and MPU (microprocessor unit) are interchangeable.
– The CPU encompasses both the Arithmetic Logic Unit (ALU) and the control unit of a computer system.
– When the CPU is integrated onto a single IC, it is designated as a µP, also known as an MPU.
– When coupled with memory and I/O devices, the configuration transforms into a MICROCOMPUTER.
– Various IC vendors, including Motorola, Intel, Texas Instruments, Zilog, and National Semiconductors, produce a multitude of different MPUs.
– Significant disparities exist in parameters such as word size, the repertoire of executable instructions, available external control signals, and the addressable memory capacity.

Microcontroller

– A microcontroller unit (MCU) integrates a microprocessing unit (MPU), memory, and input/output (I/O) circuitry within a singular chip.
– This chip is capable of executing control operations autonomously, eliminating the necessity for external circuitry.
– For instance, notable examples include the Motorola MC68HC11, which can also function as a microprocessor in an expanded multiplexed mode, and the Intel 8051.

Microprocessors vs microcontrollers

– Microprocessors serve as the high-performance, versatile “brains” in personal computers (PCs) and workstations.
– Their functionalities include instruction decode and control, arithmetic/logic operations, registers, timing, and external control.
– These components typically range in cost from $75 to $500, with an annual demand reaching tens of millions.
– Microcontrollers, on the other hand, are devices characterized by high levels of integration tailored for embedded control.
– They encompass microprocessor functions alongside on-chip memory and peripheral functions such as ports and timers.
– Often described as the “Swiss army knife” of microprocessor technology due to their multifunctionality.
– Microcontrollers typically range in cost from $1 to $25, with an annual demand in the billions.

– Microprocessor:
– Encompasses a memory management unit and ample cache capacity.
– Emphasizes performance as the primary feature (cost being significant but secondary).
– Primarily employed in desktop machines.

– Microcontroller:
– Integrates RAM and ROM with no cache provision.
– Comprises numerous peripherals.
– Commonly utilized in “embedded” applications, frequently entailing real-time control.
– Key attributes encompass low cost, minimal power consumption, abundance of integrated peripherals, swift interrupt response time, and adequate RAM and ROM capacity.

Bottom-up view of microcontroller systems

Microcontroller applications

– Handheld Communication Devices (low-power, character interpretation, user interface)
– Digital Cameras (low-power, exposure and focus adjustment, user interface)
– Inclinometer (angle measurement, audible and visual feedback)
– Keyboard Interfaces (scanning, debouncing, auto-repeat, diagnostic capabilities)
– Data Modems (one for data transmission, one for command processing)
– Plotting Devices (interpretation of commands, encoder utilization, motor management)
– Color Copying Machines (paper alignment, color calibration, sensor integration)
– Automated Payment Terminals (card scanning, dialing, carrier connection)
– Automated Lawn Sprinkler Controllers (timer functions, valve manipulation, user interface)
– Instrumentation Equipment (user interface, GPIB connectivity, data computation)
– Closed-Loop Engine Management Systems (fuel/air mixture regulation, ignition timing, pressure sensing)
– Antilock Braking System Control Units (traction monitoring, brake control mechanisms)
– Dynamic Ride Control Systems (suspension adjustments for optimal performance)

Block Diagram of a Motorola M68HC11 Based Applications Example: An Emergency Control System

Comparison of some popular microcontrollers

• Motorola HC11
Within the HC11 family, there exists a diverse array of options, spanning from individual chips to more expansive microcontrollers equipped with bank-switching capabilities.

• Motorola HC12
The HC12 family represents a progression from the HC11, boasting improved performance, enhanced memory management, and an expanded range of features.

• Motorola 6805
Serving as a step down from the HC11, the 6805 family features a greater selection of single-chip configurations, compact packaging options, and a reduced cost.

• Microchip PIC
PIC devices offer widespread availability, affordability, high speed, and a multitude of variations, albeit with limited memory maps and subpar compiler support.

• Intel 8051
Among the earliest microcontroller families, the 8051 remains highly prevalent. Available from multiple suppliers at economical prices, these devices offer decent tool support and present a seamless transition to more advanced and capable models.

What is EE447 about?

• In EE447, the MPU selected is the MC68HC11.
• You’ll delve into:
– Its integration with memory and I/O devices to create a microcomputer based on the 68HC11, and
– Programming techniques to execute diverse operations.
• The knowledge acquired about the 68HC11 is transferable and can be applied to any other MPU or microcomputer encountered in the future.

Major features of Motorola M68HC11

• HCMOS Technology implemented for low power consumption and high-speed performance
• On-chip storage includes RAM, ROM, and EEPROM
• Enhanced functionality of the MC6801 core, featuring improved instruction sets
• Supports two operating modes and two test modes for versatile usage
• Includes on-chip counter/timer functionality
• Features on-chip analog-to-digital conversion capability
• Equipped with both parallel and serial ports directly integrated onto the chip
• Enhanced interrupt capabilities compared to earlier models, supporting 21 interrupt vectors
• Offers fault detection features for major errors such as power issues, illegal instructions, and processor hang-ups
• Available in over 25 different versions with variations in pin counts, packaging, and memory configurations
– Varied RAM sizes ranging from 192 to 1.25K bytes
– ROM sizes ranging from 4K to 32K bytes
– EEPROM capacities ranging from 512 to 2K bytes
– Options for ROM, EPROM, or EEPROM program memory
– Memory maps may differ between versions
– Diverse I/O capabilities including timers, chip selects, DMA channels, A/D types, etc. may vary between versions

Modes of operation

There are two operating modes and two test modes for the microcontroller.

Operating modes:
1. Single chip operation:
– No external address and data bus functions are required.
– The CPU can solely access on-chip memory.
– Ports B and C serve as general-purpose parallel input/output.
– All necessary software to control the microcontroller unit (MCU) must reside in internal memory.
– Execution begins at address $E000 upon reset, which is located in ROM.

Expanded multiplexed

– Time-multiplexed address-data buses facilitate access to external memory and peripheral devices.
– Port B serves as the output for the high byte of the address.
– Port C handles the output for the low byte of the address and facilitates bidirectional data transfer with its 8-bit data capabilities.
– An external address latch is necessary for proper functioning.
– Execution commences at the address $E000.

Single chip mode
Expanded multiplexed mode

• Unique Bootstrapping Mechanism:
– Upon power-up or reset, the program stored in the bootstrap ROM is initiated.
– The CPU remains idle, awaiting the download of a 256-byte program segment via the serial link, which is then stored commencing at address $0000.
– Subsequently, program execution commences at address $0000, facilitating the downloading of a diverse range of programs.

• Specialized Testing Mode:
– Primarily intended as a testing mode for manufacturers.
– Overrides certain automatic protection mechanisms, presenting potential risks.

Input/Output Ports:
– Port A (8 bits): Additionally utilized for timer functions.
– Port D (6 bits): Also serves for asynchronous (SCI) and synchronous serial (SPI) I/O.
– Port E (8 bits): Functionally employed for A/D conversion.
– Port B (8 bits): Doubles as an address in expanded mode.
– Port C (8 bits): Simultaneously functions as data/address in expanded mode.

MC68HC11 detailed block diagram

Programming languages

– Application Programs:
– Users interact with pre-existing software packages.
– Limited flexibility beyond their intended purpose.
– Examples include Excel, Netscape, Word, etc.

– High-Level Language (HLL):
– Users develop programs to execute specific tasks.
– Offers high flexibility and ease of use once the language is mastered.
– Examples encompass C, C++, Java, Fortran, etc.

– Assembly Language:
– More challenging to utilize compared to HLLs.
– Dependent on the machine and its configuration.
– Requires in-depth knowledge of the microprocessor and its instruction set.
– Still employed in scenarios demanding exceptionally high performance and concise programs.

– Machine Code:
– Represents the processor’s native language.
– Programs are expressed as actual bytes stored in memory.
– Not designed for human comprehension.

Programming procedure


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.