100% found this document useful (1 vote)
55 views13 pages

Microcontrollers: 1 Microcontroller Components

A microcontroller consists of a microprocessor, memory, and input/output interfaces integrated onto a single chip. The microprocessor fetches and executes instructions from memory and contains components like an ALU, control unit, and registers for data storage and addressing. Memory includes RAM for temporary data and ROM for permanent programs. Input/output interfaces connect the microcontroller to external devices using techniques like buffers, handshaking, and polling or interrupts to transfer data.

Uploaded by

johnny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
55 views13 pages

Microcontrollers: 1 Microcontroller Components

A microcontroller consists of a microprocessor, memory, and input/output interfaces integrated onto a single chip. The microprocessor fetches and executes instructions from memory and contains components like an ALU, control unit, and registers for data storage and addressing. Memory includes RAM for temporary data and ROM for permanent programs. Input/output interfaces connect the microcontroller to external devices using techniques like buffers, handshaking, and polling or interrupts to transfer data.

Uploaded by

johnny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Microcontrollers

1 Microcontroller components

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

A microprocessor system generally consists of three parts: A microprocessor, some kind of


memory, and input and output interfaces that connect the microprocessor to the memory
and to external elements. A microprocessor is a single-chip central processing unit (CPU).
When a microprocessor is used in a control system, it is integrated with memory and a
variety of input and output interfaces on a single microcontroller. The memory can be RAM
or ROM, and stores bit words for the processor. Information is transferred using ports and
buses, and these can transfer bits or voltage levels for power and signaling.

2 Microprocessors

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

1
The microprocessor processes data by fetching instructions from the memory, decoding them,
and executing them. The architecture of the processor varies based on its application, but
there is a general form and some common components:
Arithmetic and Logic Unit (ALU): This unit performs the data manipulation.
Control Unit: This determines the timing and sequence of operations by generating
a timing sequence. For example, a microprocessor with a frequency of 1 MHz has a clock
period of 1 µs and instructions take multiple (2-12) clock cycles. The cycle is the time unit
of the processor.
Registers: Internal data on the CPU, a kind of temporary memory. These registers
may have different functions, some of which are listed below
Accumulator register (A): This register is where data for input to the ALU is stored.
First, the processor supplies an address of the desired memory bit-word to the address bus,
and this address is used so that the CPU can read that data and load it into the data bus.
Since operations may involve more than one number, the first number may be loaded into the
accumulator, while the second number is accessed directly from memory. Then, the output
is loaded into the accumulator.
Status register: This register contains individual bits which each represent a special
information or status. These bits are called flags. For example:
Flag 1 0
Z Result is zero Result is not zero
N Result is negative Result is not negative
C Cary is generated Carry is not generated
V Overflow No overflow
I interrupt ignored interrupt processed
some notes: carry indicates that the addition of two numbers causes the carry of the
most significant bits: 111 + 001 = (1)000. This also occurs in subtraction: 000 - 001 =
111. overflow Is in effect with signed numbers. In these numbers, the leftmost bit indicates
whether a number is positive or negative. If two numbers with the signed bit off are added,
and the signed bit is on (or vice-versa) it indicates the addition overflowed into he sign bit,
and the overflow flag is activated.
Program counter register (PC) or instruction pointer (IP): This address is used
for the processor to keep its place in the program its running. Each instruction has an
address, and as they’re executed, this register is updated to point to the new instruction.
It’s normally incremented unless the instruction points it to a new point in the program.
Memory address register (MAR): This contains the address of data, such as the
second number during an addition.
Instruction register (IR): This stores an instruction for execution. This is known as
the fetch-execution cycle.
General-purpose registers: Temporary storage for data, addresses, or other informa-
tion shuffling.
Stack-point register (SP): The stack is a special area of the memory in which program
counter values can be stored when a subroutine part of a program is being used. This register
sets the address which defines the top of the stack.

2
2.1 Example registers
These are examples from the Motorola Freescale M68HC11

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Port A is a data register with three input lines, four output lines, and one line that can
be either. There is a complimentary control register with a variety of functions.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

The C register can be in or out, and includes a direction register where the bits in the
direction register determine the direction of each bit in the main register.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

The E port is input only, and can be used as the input to an internal ADC, when the
ADC is active.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

3
2.2 Multiplexer
The way that signals are controlled by the processor and other elements is through logic
gates. One particular form of this is the multiplexer, which can receive multiple signals, and
select one to output.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

4
3 Memory

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Memory elements are essentially large numbers of storage cells which each can hold a bit. The
storage cells are grouped into locations, with each location storing a bit-word and having an
address. So, with a 4-bit address, you have 16 addresses and 16 different memory locations.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Read-only memory (ROM): This is memory that is programmed during manufacture


of the chip , and cannot be rewritten during operation, so it’s typically used for permanently
installed programs.

5
Programmable ROM (PROM): This is ROM that an be programmed once by a user.
Each bit starts at 0, but can be permanently fused open.
Erasable and programmable ROM (EPROM): Like EPROM in function, but they
can be erased with ultraviolet light and reprogrammed.
Electrically erasable (PROM): Similar to EPROM, but erased with ultraviolet light.
Random-access memory (RAM): Temporary data, for current operations.
ROM is sometimes referred to as firmware, and RAM is called software.

3.1 Example: Washing machine

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

A generic form of the microcontroller can be seen above, and the application of this controller
to a washing machine below.

6
Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

4 Input/output
Microcontrollers often include ports so that the processor can communicate with peripheral
devices. These often have varying speeds and characteristics, so these controllers often have
interface chips, which can synchronize data transfers.

• Electrical buffering isolation

• Timing control

• Code conversion

• Changing the number of lines (bits)

• serial-to-parallel transfer (or vice-versa)

• Analog to digital conversion (or vice versa)

7
4.1 Buffers

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

A buffer connects two parts of a device and prevents unwanted interference. A common
form is the tri-state buffer, which can enable 0 or 1 to pass through, or be disabled for a
high-impedance. These are often used to hold data until the CPU requests it, or multiplex
data to different peripherals.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

8
4.2 Handshaking

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Unless two devices are operating at exactly identical rates, they must use a handshake to
share data. For parallel data transfer, microcontrollers commonly use strobe and acknowl-
edge:

1. Peripheral sends a DATA READY signal to the in/out section

2. CPU reads that DATA READY is active

3. the CPU reads data from the in/out section and sends an INPUT ACKNOWLEDGED
signal

4. The peripheral reads the INPUT ACKNOWLEDGED signal and can send more data

In the below example, the processor sends either a pulse or an interlock signal over STRA,
and waits for the peripheral to respond by sending either a rising or falling signal over STRB.
At that point, the processor can send its data.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

a full handshake occurs when two signals are sent, the first indicating the processor is
ready to receive, and the second to indicate the data has been read.

9
4.3 Polling and interrupts

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

The microcontroller in/out is completely controlled by the program, so when peripherals


need attention they have to find a way to signal that, usually through an interrupt, which
is a single bit of an input line. The program will periodically check these bits in what is
termed as polling, and use that to make a decision about the program.

4.4 Serial interfacing


Serial refers to an interface that sends bit sequentially over single line. This can be done two
ways:
asynchronous transmission is when the receiver and transmitter use their own clock
signals, so the receiver can’t know when a word starts or stops. Instead, the transmission
includes a start bit and a stop bit to indicate the beginning and end of a bit-word. The stop
bit can also be thought of as a stop-period, as the transmission typically lasts longer than a
standard bit transmission.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

synchronouse transmission is when the receiver and transmitter share a clock signal,
so it is straightforward to synchronize transmission and reception.

10
4.5 Peripheral interface adapters

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

These are programmable devices which can be used as adapters for peripherals.A typical
PIA will contain:
peripheral interface register: Output ports operated differently from input ports
because they must be able to hold the data for the peripheral. The register is latched (ie
connected) when used for output, and unlatched when used for input.
data direction register indicates whether the lines are inputs or outputs.
control register determines the active logical connections
control lines, used for interrupts

11
Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

4.6 Serial communications interface

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

To change data from a serial form to a parallel form, microcontrollers use a Universal
Asynchronous Receiver/Transmitter (UART). The common form of this devices is
the Asynchronous Cummunications Interface Adapter (ACIA). Data flow between
microcontroller and ACIA occurs over an 8-bit bus, and controlled by a read/write signal
to the ACIA. Chip select lines are used to select a particular ACIA, and the register select
line is used to select the register within the ACIA; if high, the data transmit and receive
lines are selected, otherwise the control and status registers are selected. The peripheral side
includes two serial data lines: one for tranmission, one for reception; and three control lines:
clear-to-send, request-to-send, and data-carrier detect (which can be used to detect whether
incoming data is valid, for instance in a modem to see if the connection has been broken).

12
One example is the control of an LED display, shown below. Four input signals determine
what character is displayed on each panel. Note that RBI stands for ripple-blanking input,
and can be used to turn off the display if, for instance, you don’t want a left-hand zero.

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

Credit: Bolton, Mechatronics: Electronic control systems in mechanical and electrical engineering

13

You might also like