0% found this document useful (0 votes)
2 views12 pages

MTR204-2 Microcontroller Features and Assembly Language Programming

The document provides an overview of microcontroller design, detailing its core elements such as the processor, memory, and I/O peripherals, as well as their applications in various devices. It discusses different microcontroller architectures, types, and families, highlighting the PIC18 family and its features. Additionally, it covers programming basics, including the use of assembler language and the steps involved in creating and testing a microcontroller program using MPLAB.

Uploaded by

Othniel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

MTR204-2 Microcontroller Features and Assembly Language Programming

The document provides an overview of microcontroller design, detailing its core elements such as the processor, memory, and I/O peripherals, as well as their applications in various devices. It discusses different microcontroller architectures, types, and families, highlighting the PIC18 family and its features. Additionally, it covers programming basics, including the use of assembler language and the steps involved in creating and testing a microcontroller program using MPLAB.

Uploaded by

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

Microcontroller Design, Signals and

Systems (MTR 204)- 2


Microcontroller System.
A microcontroller is a compact integrated circuit designed to govern a specific operation
in an embedded system. A typical microcontroller includes a processor, memory and
input/output (I/O) peripherals on a single chip. Microcontrollers are used in a wide array
of systems and devices. Devices often utilize multiple microcontrollers that work
together within the device to handle their respective tasks. The microcontroller is found
in a number of household and industrial products eg, TV remote control units,
cellphones, hi-fi equipment, industrial robots, furnaces communications and internet of
things (IoT) deployments etc. A microcontroller is embedded inside of a system to
control a singular function in a device. It does this by interpreting data it receives from
its I/O peripherals using its central processor. The temporary information that the
microcontroller receives is stored in its data memory, where the processor accesses it
and uses instructions stored in its program memory to decipher and apply the incoming
data. It then uses its I/O peripherals to communicate and enact the appropriate action.

Core Elements of the Microcontroller


Involves

 The processor (CPU) - A processor can be thought of as the brain of the device.
It processes and responds to various instructions that direct the microcontroller's
function. This involves performing basic arithmetic, logic and I/O operations. It
also performs data transfer operations, which communicate commands to other
components in the larger embedded system.
 Memory -- A microcontroller's memory is used to store the data that the
processor receives and uses to respond to instructions that it's been
programmed to carry out. A microcontroller has two main memory types:
Program memory and data memory. Program memory, which stores long-term
information about the instructions that the CPU carries out. Program memory is
non-volatile memory, meaning it holds information over time without needing a
power source. Data memory, which is required for temporary data storage while
the instructions are being executed. Data memory is volatile, meaning the data it
holds is temporary and is only maintained if the device is connected to a power
source.
 I/O peripherals -- The input and output devices are the interface for the processor
to the outside world. The input ports receive information and send it to the
processor in the form of binary data. The processor receives that data and sends
the necessary instructions to output devices that execute tasks external to the
microcontroller.
Other supporting elements of a microcontroller include:
 Analog to Digital Converter (ADC) -- An ADC is a circuit that converts analog
signals to digital signals. It allows the processor at the center of the
microcontroller to interface with external analog devices, such as sensors.
 Digital to Analog Converter (DAC) -- A DAC performs the inverse function of an
ADC and allows the processor at the center of the microcontroller to
communicate its outgoing signals to external analog components.
 System bus -- The system bus is the connective wire that links all components of
the microcontroller together.
 Serial port -- The serial port is one example of an I/O port that allows the
microcontroller to connect to external components. It has a similar function to a
USB or a parallel port but differs in the way it exchanges bits.

A microcontroller's processor will vary by application. Options range from the simple 4-
bit, 8-bit or 16-bit processors to more complex 32-bit or 64-bit processors.
Microcontrollers can use volatile memory types such as random access memory (RAM)
and non-volatile memory types -- this includes flash memory, erasable programmable
read-only memory (EPROM) and electrically erasable programmable read-only memory
(EEPROM).
Microcontroller architecture can be based on the Harvard architecture (b) or von
Neumann (a) architecture, both offering different methods of exchanging data between
the processor and memory. With a Harvard architecture, the data bus and instruction
are separate, allowing for simultaneous transfers. With a Von Neumann architecture,
one bus is used for both data and instructions.
Microcontroller processors instruction set can be based on complex instruction set
computing (CISC) or reduced instruction set computing (RISC). CISC generally has
around 80 instructions while RISC has about 30, as well as more addressing modes,
12-24 compared to RISC's 3-5. While CISC can be easier to implement and has more
efficient memory use, it can have performance degradation due to the higher number of
clock cycles needed to execute instructions. RISC, which places more emphasis on
software, often provides better performance than CISC processors, which put more
emphasis on hardware, due to its simplified instruction set and, therefore, increased
design simplicity, but because of the emphasis it places on software, the software can
be more complex. Which ISC is used varies depending on application.

Microcontroller Systems also feature input and output pins to implement peripheral
functions. Such functions include analog-to-digital converters, liquid crystal display
(LCD) controllers, real-time clock (RTC), universal synchronous/asynchronous receiver
transmitter (USART), timers, universal asynchronous receiver transmitter (UART) and
universal serial bus (USB) connectivity. Sensors, motor control interfaces, usb
interfaces, Ethernet interfaces etc. are also often attached to microcontrollers.

The PIC 18
Microcontroller Appearances
Microcontroller are made in a number of different forms, usually using plastic or ceramic
as the packaging material. Interconnection with the outside world is provided by the pins
on the package. It would have good number of pins most of which are used for
input/output whilst some would be for power and earth connection made.

Microcontroller Types and Families


Common Microcontrollers include the Intel MCS-51, often referred to as an 8051
microcontroller, which was first developed in 1985; the AVR microcontroller developed
by Atmel in 1996; the programmable interface controller (PIC) from Microchip
Technology; and various licensed Advanced RISC Machines (ARM) microcontrollers.
Other microcontroller manufactures and sellers include NXP Semiconductors, Renesas
Electronics, Silicon Labs and Texas Instruments.
Each manufacturer builds a microcontroller family around a fixed microprocessor core.
Different family members are created by using the same core, combining with it different
combinations of peripherals and different memory sizes. The diagram shows an
example of 3 families from a manufacturer. One core might be 8-bit with limited power,
another 16-bit and another a sophisticated 32-bit machine. To each core is added
different combinations of peripheral and memory size, to make a number of family
members. Because the core is fixed for all members of one family, the instruction set is
fixed and users have little difficulty in moving from one family member to another.
The table below shows some Microchip Pic families. Take note of their differences.

Every member of any one family shares the same core architecture and instruction
The PIC18 family
The PIC18 family utilizes a 16-bit program word architecture and incorporates an
advanced RISC architecture with 32 level-deep stack, 8x8 hardware multiplier, and
multiple internal and external interrupts. With the highest performance in Microchip’s 8-
bit portfolio, the PIC18 family provides up to 16 MIPS and linear memory. PIC18 is the
most popular architecture for new 8-bit designs where customers want to program in C.
Choose from over 150 PIC18 products supporting both 3V and 5V applications with
packages ranging from 18 to 100 pins. Integration is key on the PIC18 devices, with
support for connectivity and human interface peripherals including: USB, Ethernet,
touch sensing, LCD display drivers and CAN.

Pin connection diagram of the PIC18F2220.


PIC18F2220 Block Diagram

The PIC controller has a Havard structure and we should be able to identify two address
buses (one for program memory, and the other for data memory and all peripherals)
and two data buses (again, one for program memory, and one for data memory and
peripherals). The data bus for data memory and peripheralsis serves primarily the data
memory, the General-Purpose Input/Output (GPIO) and the ‘Timer X’ peripheral.
Application Examples

Assembly Code
Microcontroller Types and Families
The first step in writing code for a microcontroller is knowing and understanding the type
of information found in the data sheet of the device used for programming. The data
sheet contains information about the features, memories, core and peripheral modules
of the microcontroller. Also included in the data sheet are the functional descriptions
and base addresses of the peripheral modules, the names and addresses of the
registers and other functional and electrical characteristics. (Download PIC18 datasheet
from www.microchip.com)

Starting a Program
We will now focus on the essentials of Assembler programming and how to write simple
Assembler programs using MPLAB to simulate.

A microcontroller has an instruction set and it can recognize each instruction and
execute it. The program is a list of instructions drawn from the microcontroller
instruction set. These instructions are read in binary from its program memory. The
programmer must find a means of breaking down and translating his/her ideas into
steps that the microcontroller would undertake, where each step ultimately must be an
instruction from its instruction set.

The programmer writes the source code (program) in Assembler language. This is then
assembled by the Cross-Assembler running on the host computer test the program by
simulation. When satisfied with the program, the developer will then download it to the
program memory of the microcontroller itself, using either a stand-alone ‘programmer’
linked to the host computer or a programming facility designed into the embedded
system itself. He/she will then test the program running in the actual hardware.
Assembler Program format:

• Label. A label for a line is optional. When it is first specified, the label must
start in the left-most space of the line. The Assembler will interpret
anything starting in this space as a label. Once defined in this way, a label
can be used as an operand. Labels must start with an alphabetic
character or underscore, but not a number. Labels can stand alone on a
line, in which case the label is adopted by the next line that contains an
instruction.
• Instruction mnemonic. This is drawn from the instruction set. It may be
placed anywhere on the line, except starting at the far left. It should be
separated from any label by at least one blank space.
• Operand. These must conform exactly to the format specified in the
instruction set. For better intelligibility, labels are often used rather than
numbers. If there is more than one operand they are separated by a
comma.
• Comment. This is optional, and is used to add information to the program
and improve its intelligibility to the human reader. A comment must always
start with a semicolon. The Cross-Assembler ignores everything that
follows a semicolon in any line. Comments can follow instructions on a
line; alternatively, a whole line can be used just for commenting.
A line of the Assembler program can contain an instruction, it can be a comment only,
or it can be left completely blank (this sometimes helps to improve layout and
readability).

Projects in MPLAB will have the following basic step: -


1. Select Device
2. Create Project
3. Select Language Tools
4. Put Files in Project
5. Create Code
6. Build Project
7. Test Code with Simulator

Start>Programs>Microchip>MPLAB IDE vx.xx>MPLAB IDE.


Configure>Select Device. PIC18F8722
Project>Project Wizard. Next>.
Select Microchip MPASM Toolsuite in the Active Toolsuite list box
Add Files
Choose the file named 8722tmpo.asm. If MPLAB IDE is installed in the default
location, the full path to the file will be:
C:\Program Files\Microchip\MPASM Suite\Template\Object\8722tmpo.asm
View>Project.
Project>Build All
Project>Build Options>Project
Create Code
The instruction set is grouped into four basic categories: -
• Byte-oriented operations
• Bit-oriented operations
• Literal operations
• Control operations

Project>Build All
Debugger>Select Tool
Debugger>Reset>Processor Reset
View>Watch
Debugger>Run
Debugger>Step Out.
Debugger>StopWatch
Debugger>Reset
Debugger>Run

SERIAL PORT-COM PORT

Reading Materials & Texts


 Muhammad Ali Mazidi, Rolin D McKinlay, Danny Causey, The PIC
Microcontroller and Embedded systems – Using Assembly and C for PIC18,
Prentice Hall, 2008.

 Microchip Technology Inc. MPLAB® IDE Users Guide- DS51519B 2006

You might also like