element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Essentials
  • Learn
  • Learning Center
  • Essentials
  • More
  • Cancel
Essentials
Documents The Basics of Microcontrollers
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Essentials requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: pchan
  • Date Created: 5 Apr 2022 8:39 PM Date Created
  • Last Updated Last Updated: 5 May 2023 4:40 PM
  • Views 26743 views
  • Likes 12 likes
  • Comments 24 comments
Related
Recommended

The Basics of Microcontrollers

essentials logo MCUs Series - Part 5 - Basics of Microcontrollers

A microcontroller unit (MCU) is an intelligent and versatile semiconductor IC (integrated circuit) that can be programmed to control a wide range of electronic hardware. The primary component of an MCU is the processor unit, responsible for the calculation and control tasks. Supporting the processor unit are memory modules, communication interfaces, and various other peripherals. In modern electronics, microcontrollers are ubiquitous and function as the brains for a wide range of devices, including robots, appliances, drones, industrial machinery, vehicles, and game controllers.
Related Components | Test Your Knowledge test link

2. Objectives


Upon completion of this module, you will be able to:

  • Understand the basic concepts and operation of MCUs
  • Describe the components that make up a typical MCU
  • Discuss the architecture of an MCU, using a Toshiba MCU as an example
  • Explain the basics of software development with an MCU

3. History

Back to Top

In 1971, Intel Corporation developed a 4-bit microcontroller called the i4004 that was originally designed for use in calculators manufactured by a company called BUSICOM. The i4004 was later sold as a general purpose microcontroller. Intel followed this with 8-bit microcontrollers, such as the i8008, i8080A, and i8085. The 8086, a 16-bit microcontroller, was later released in 1978.

Around the same time period in 1973, Toshiba developed the TLCS-12, a 12-bit microcontroller that found its way into Ford vehicles as the in-vehicle engine controller. Since then, Toshiba has expanded its range of microcontrollers, covering 4-bit to 32-bit designs and higher.

4. Basic Concepts

Back to Top

What Is an MCU?

An MCU is essentially a brain that controls the hardware of an electronic device. The MCU receives input signals from a variety of sources: buttons, sensors, communications data such as Ethernet, and more. Software in the MCU interprets the input signals and responds with commands that control the peripheral circuitry, such as motors or displays.

What’s Inside an MCU?

An MCU is comprised of several pieces, the primary of which is the central processing unit (CPU). The CPU handles all of the logic and calculations.

What Is a Large Scale Integrated Circuit?

A Large Scale Integrated Circuit (LSI) is an integrated circuit (IC) that contains 1,000 or more elements. A microcontroller is an example of an LSI.

In order to store data and code, an MCU has onboard memory that the CPU can write to and read from. There are two types of memory: RAM (Random Access Memory), which can read and write data, and ROM (Read Only Memory), which mainly stores program code and, as its name suggests, is read-only. Memory is either volatile or non-volatile. Volatile memory loses its stored data when power is turned off; non-volatile memory does not. RAM is considered volatile memory, and is typically used to store program calculations and for the runtime of software. ROM is non-volatile memory, and is suitable for storing data that doesn’t change, such as program code and configuration. Hard drives are also considered non-volatile memory.

RAM (Volatile)
SRAM (Static RAM) Bipolar type
Stores information by flip-flop circuit
Used for registers and cache memory
High speed, low integration, large capacity, and low power consumption
DRAM (Dynamic RAM) MOS type
Stores information by capacitor
Needs refresher at regular intervals
Used for main storage
Low speed, high integration
ROM (Non-Volatile)
Mask ROM
Write information in manufacturing
Impossible to write by users
PROM OTP
Programmable ROM
Possible to write only once by users
EPROM
Write electrically
Possible to erase by ultraviolet light
EEPROM
Electrically writable and erasable
Flash
Electrically writable and erasable
Electrically writable and erasable with the block unit
Table 1: Memory type (RAM and ROM)

In order to interface with the outside world, an MCU must have an input and an output (I/O). I/O allows external devices to exchange data and control signals with the microcontroller. The I/Os on an MCU are referred to as ports, and their addresses are called port addresses.

The bus line, or system bus, is the wiring that connects the CPU, the memory, and the I/O together. There are three types of bus lines: data buses, address buses, and control buses.

figure 1
Figure 1: Bus line type

The data bus enables the exchange of data between the CPU and memory, as well as the CPU and I/O. This data includes calculation variables, calculation results, and input and output signals for external devices.

The address bus is a signal line that carries the addresses of the various parts of the MCU. This data contains the addresses specifying the location of the data when reading, and where data should be saved when writing.

The control bus is a signal line carrying the command regarding whether to “read” or “write” to the location specified by the address bus. When instructed to “write” by the control bus, the memory and I/O specified on the address bus receive the data that was sent by the data bus. When instructed to “read,” the data is output to the data bus.

Programming a Microcontroller

An MCU is a versatile device, because it is capable of being programmed to perform a wide range of functions, including logic and arithmetic calculations, receiving inputs from sensors, and controlling external devices. Its programmability is what makes an MCU one of the most powerful tools in modern engineering.

The software of a typical MCU runs sequentially; that is, the CPU will read an instruction at a specified address and execute it before moving on to the next address. This is in contrast to parallel processing, where instructions are executed at the same time, or in parallel. Field Programmable Gate Arrays (FPGAs) are capable of parallel processing, as are MCUs in which the processor has multiple cores.

MCUs are typically programmed with a high level language, such as C or Java, where the code is intuitive enough to be read and understood by a human. The grammar of high level languages is very close to the English language. Languages like C or Java are standardized and can be used with most different types of MCUs; there is no need to learn a new programming language when changing between MCUs. Once the code is written, it is compiled into the machine language that the processor can understand.

void main {
if(key1 == 1) {
led1 = 1;
} else {
led1 = 0;
}
}

The code above shows a simple example in C (turning an LED on or off depending on the status of a switch).

Some MCUs can be programmed in Assembly language, a lower level language that uses symbolic words with a one-to-one correspondence to machine language. Assembly language usually has different grammar and notation, depending on the MCU. When switching between MCUs, Assembly developers must learn the Assembly language of the new MCU.

LD A, 0x55
LD B, 0x33
ADD A, B
LD (0x100), A
JP 0x9000

The code above shows an example of Assembly language.

  • The first command (LD A, 0x55) tells the processor to load the data in the 0x55 address to a register A.
  • The next command (LD B, 0x33) loads the data in 0x33 to register B.
  • The third command (ADD A, B) adds the data in A and B together, storing the result in the first register (A).
  • The fourth command (LD (0x100), A) loads the data in register A to address 0x100.
  • The last command (JP 0x9000) tells the processor to jump to address 0x9000 and run the command stored at that address.

Microcontroller Architecture

This section describes the architecture of an MCU, using the Toshiba TLCS-870/C1 as an example. Other MCUs will differ in configuration and architecture; however, the design principles are generally similar.

figure 2
Figure 2: Functional Block Diagram of an 8-bit Microcontroller

Figure 2 illustrates the architecture of an 8-bit MCU. The CPU core includes an arithmetic unit that performs calculations and three separate storage circuits storing the data, the read instructions, and the memory addresses of the read instructions.

The different units shown in Figure 2 are as follows:

  • PSW (Program Status Word): A register that keeps track of the current operation. It holds the operation results and the state of the instruction execution result.
  • General-purpose Register: A storage unit for the data. General-purpose registers are named based on their location, and have names like W, A, B, C, etc.
  • Accumulator: The place that calculation results are stored. In the TLCS-870/C1, ten registers, W, A, B, C, D, E, H, L, IX, and IY, have the accumulator role.
  • Program Counter (PC): The register that stores the memory address of the next instruction that should be read.
  • ALU (Arithmetic Logic Unit): The arithmetic circuit that performs calculations.
  • Instruction Register: A register that temporarily stores the read instructions.
  • Instruction Decoder: The unit that decodes the instruction stored in the instruction register, then sends it to the control unit.
  • Interrupt Control Circuit: The circuit that controls the interrupt function. An interrupt occurs when the program being executed is suspended in order to execute another one.

Each of these units performs complex operations in support of the MCU’s functions. The next section details these operations, referencing the Toshiba TLCS-870/C1.

Program Counter (PC)

The program counter (PC) is the register that manages which instruction should be executed next. The PC stores the address of the next instruction that should be executed. Generally, the address stored is the next sequential address after the address currently being executed; however, in the case of an interrupt instruction, the jump destination address is stored.

The CPU reads the instruction stored in the address in the program counter and executes it in sequence.

figure 3
Figure 3: Calling the next instruction storage address (Program Counter)

Figure 3 shows that 0x8020 is stored in the PC. This means the instruction stored at address 0x8020 will be the next instruction to be executed (unless an interrupt command is received).

General-Purpose Register

General-purpose registers store the data used by the CPU, including data used for calculations, as well as calculation results. In 8-bit mode, the TLCS-870/C1 has eight registers, W, A, B, C, D, E, H, and L. These can be paired to use as 16-bit registers, the names of which would become WA, BC, DE, and HL.

General-purpose register of TLCS-870/C1
W
A
B
C
D
E
H
L
← 8 bit →
← 8 bit →
← 16 bit →

Figure 4: 8-bit General-Purpose Registers in the Toshiba TLCS-870/C1

The TLCS-870/C1 also has two 16-bit registers, IX and IY, which are mainly used as index registers when accessing the memory.

IX
IY
← 16 bit →

Figure 5: 16-bit Registers in the Toshiba TLCS-870/C1

The TLCS-870/C1 has two banks of the 8-bit and 16-bit general purpose registers.

Program Status Word (PSW)

The Program Status Word (PSW) stores information on the status of the execution of a program. It typically contains the value of the program counter and overflow or carry bits that indicate the state of the ALU during runtime. The PSW stores the information necessary to enable the program to continue after handling an interrupt request.

Stack

The stack is the area in the memory registers for saving program status during interrupts. When an interrupt request occurs, the PSW, PC, and various other flags are saved in the stack. After the interrupt processing finishes, the information in the stack is restored and the program continues running.

The Stack Pointer (SP) is a register that manages the stack, and indicates the address where the status information is saved. The stack functions in a first-in-last-out (FILO) manner, where the data stored first is taken out last. A good way to visualize a stack is a vertical stack of coins; the last coin placed on the stack is always the first coin to be taken.

figure 6
Figure 6: FILO Method (First-In-Last-Out)

Adding data to the stack is called a “Push,” while reading data from the stack is called a “Pop.” The Stack Pointer advances when there is a Push, and returns when there is a Pop.

Interrupt Processing

When the MCU receives an interrupt request, the program being executed is suspended and another program executed. After the interrupt processing is completed, the MCU returns to the original program. There are two types of interrupts: software and hardware. A software interrupt occurs when the running program executes a dedicated instruction. Hardware interrupts occur when a signal is received either externally, from a dedicated interrupt terminal, or internally, from a peripheral circuit built into the MCU.

Interrupts can be maskable or non-maskable, depending on how the interrupt signal is received. Maskable interrupts can only execute if the CPU is set to allow interrupts. If interrupts are not allowed, the interrupt request signal is stored until it either executes once interrupts are allowed or is deleted when the interrupt signal is cancelled. Non-maskable interrupts execute even when interrupts are not allowed. If the CPU receives a non-maskable interrupt request, it will perform the processing unconditionally. Non-maskable interrupts are used for emergency processing, such as data backups or shutdown processes during power outages.

Integrated Development Environment

Software development using an MCU takes place in an integrated development environment (IDE). Many manufacturers provide an IDE custom tailored for their MCU. An IDE provides the compiler for the programming language used to write the code, an editor, a build manager, and a debugger. Many IDEs provide automated testing, enabling the creation of custom test cases; these can run automatically, creating a list of passes and fails.

5. Glossary

Back to Top

  • Microcontroller Unit (MCU): An integrated circuit with the functionality of a simple computer, used for controlling components in electronic systems.
  • Non-volatile Memory: A type of memory where the data is retained when the system is powered off.
  • Volatile Memory: A type of memory where the data is lost when the system is powered off.
  • RAM (Random Access Memory): A type of volatile read/write memory that stores temporary data, including calculations and working data. Because of its design, access time for data in RAM is the same irrespective of its location in the chip.
  • ROM (Read Only Memory): A type of non-volatile memory that cannot easily be modified after the manufacture of the memory device. ROM is used to store firmware and other data that is rarely modified.
  • Central Processing Unit (CPU): The unit that performs logic and calculations, and also executes control instructions.
  • Bus Line (or System Bus): The pathway in an MCU for the rapid moving of data. The bus line is also known as the Front Side Bus, local bus, or memory bus. The bus line is made up of three busses: the data bus, the address bus, and the control bus.
  • Field Programmable Gate Array (FPGA): A semiconductor IC that is designed to be easily configured or reprogrammed. FPGAs contain programmable logic blocks and reconfigurable interconnects that can always be modified after manufacturing.
  • Parallel Processing: A method of computing where two or more processes can be run simultaneously.
  • Assembly language: A low-level computer language that is intended to communicate directly with the CPU. Assembly language has a one-to-one relationship with machine code and can be directly translated.
  • Register: A piece of memory that data can be read from or written to.
  • ALU (Arithmetic Logic Unit): The component of a CPU that performs arithmetic and logic operations.
  • PSW (Program Status Word): A collection of data that keeps track of the current execution state of the system.
  • Program Counter (PC): A register that manages the memory address of the next instruction to be executed.
  • Accumulator: A register that temporarily stores the intermediate results of calculations of arithmetic and logic data in the CPU.
  • Interrupt: A request for the CPU to stop the currently executing code. Interrupts can be generated by internal or external sources.
  • Maskable Interrupt: An interrupt that does not run if the CPU is not set to allow interrupts.
  • Non-maskable Interrupt: An interrupt that processes even when the CPU is not set to allow interrupts.
  • Stack: An area in the memory registers that stores program status data during an interrupt.
  • Stack Pointer: The register that manages the stack, indicating the address where the information about the current program status is located.
  • Integrated Development Environment (IDE): A software application that provides tools that simplify the writing of code. IDEs typically include an editor, build manager, and debugging tools.
*Special thanks to Toshiba for providing technical and historical background.
Profile image
Listed below are a variety of microcontrollers available.

Product Image
Buy Now

Toshiba TMP88FW44FG
The Toshiba TMP88FW44FG is a member of the TLCS-870/X Series of 8-bit Microcontrollers. It features 36 interrupt sources, 91 pins for I/O (24 with large current output), and low power consumption modes.


Product Image
Buy Now

Toshiba TMPA910CRAXBG
The Toshiba TMPA910CRAXBG is a 32-bit RISC MCU from the TX09 Family. It features an ARM9TmCPU core and 7-layer multi-bus system, with a maximum operating frequency of 200 MHz.


Product Image
Buy Now

Raspberry Pi RP2040TR7
The RP2040 is the debut microcontroller from Raspberry Pi and features a Dual ARM® Cortex M0+ processor running at 133 MHz, 264kB on-chip SRAM, and 30 GPIO pins, 4 of which can be used as analog inputs.


Product Image
Buy Now

NXP LPC822M101JDH20J
The NXP LPC82x Series is a low-cost ARM® Cortex M0+ based, 32-bit MCU family operating at CPU frequencies up to 30MHz.


Product Image
Buy Now

Renesas R7FA6M1AD3CFM#AA0
The RA6 Series of 32-bit MCUs features ARM® Cortex-M4 core CPUs running at up to 120MHz and support for a variety of communication interfaces, including CAN, I2C, SPI, UART, and USB.


Product Image
Buy Now

ST Microelectronics STM32L011F4P6
The STM32L011 is a 32-bit MCU that features an ARM® Cortex-M0+ core CPU, up to 16kB Flash and 2kB RAM, all of which runs on an ultra-low power platform.


Product Image
Buy Now

Infineon XMC1402T038X0032AAXUMA1
The XMC1400 features ARM® Cortex-M0+ core CPUs and is designed for industrial applications, addressing the real-time control needs of motor control and digital power conversion. It also features peripherals for LED lighting applications and Human Machine Interfaces (HMIs).


Product Image
Buy Now

Maxim MAX32660GWE+
The MAX32660 features the ARM® Cortex-M4 core with floating point unit (FPU). It is designed for battery-powered devices and features ultra-low power consumption in a tiny form factor.

For more MCU products Shop Now


Test Your Knowledge

Back to Top

Microcontroller Skills 5

Microcontroller Skills 5

Complete our Essentials: MCUs V course, take the quiz, and leave your feedback to earn this badge.

Are you ready to demonstrate your microcontroller basics knowledge? Then take this 10-question quiz. To earn the MCUs V Badge, read through the module, attain 100% in the quiz, and leave us some feedback in the comments section.

More MCUs educational modules to come.

  • maskable interrupt
  • interrupt
  • system bus
  • alu
  • stack
  • microcontrollers
  • lsi
  • essentials
  • register
  • microcontroller unit
  • counter
  • microcontroller
  • mcu
  • cpu
  • accumulator
  • mcus
  • Architecture
  • ess_module
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • bashir1961
    bashir1961 over 3 years ago +1
    strictly speaking, intel 4004 and friends are not microcontrollers but microprocessors.
  • phoenixcomm
    phoenixcomm over 2 years ago in reply to bashir1961 +1
    So True, and it was used for traffic signals.
  • Former Member
    Former Member 7 months ago

    Interesting quiz

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • maxpowerr
    maxpowerr over 2 years ago

    Nice quiz, I finally finished it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Sudeep AJ
    Sudeep AJ over 2 years ago

    Thanks for explaining MCUs in a nutshell well!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 2 years ago in reply to phoenixcomm

    and calculators

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kmikemoo
    kmikemoo over 2 years ago

    Nice overview.  I remember programming in Assembly.  Made BASIC look advanced.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • FThierry
    FThierry over 2 years ago

    Done

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • sateesh729255
    sateesh729255 over 2 years ago

    good

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 2 years ago

    BTW address lines are part of the Address Bus and that is the proper term THEY are BUSSES NOT LINES!!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 2 years ago in reply to bashir1961

    So True, and it was used for traffic signals. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 2 years ago

    No Cheating 100% First Time. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube