Lec (1 )
GETTING STARTED WITH
PIC MICROCONTROLLERS
Lecturer: Arwa Alaaeldin Mursi Elamin
2023
MICROPROCESSOR
A microprocessor is an integrated circuit (IC) which incorporates core functions
of a computer's central processing unit (CPU). It is a programmable
multipurpose silicon chip, clock driven, register based, accepts binary data as
input and provides output after processing it as per the instructions stored in
the memory.
Microcontroller
- A microcontroller (sometimes abbreviated µCµC,, uC or MCU
MCU)) is a small
computer on a single integrated circuit containing a processor core,
core, memory
memory,,
and programmable input/output peripherals. It can only perform simple task. A
microcontroller is often described as a ‘computer
‘computer
computer--on
on--a-chip
chip’.’.
- Microcontroller - A single chip used to control other devices . It is a single
chip that consists of CPU, Memory, I/O ports, timers and other peripherals
Microcontroller Vs Microprocessor
Embedded System VS General
Purpose System
General purpose system like computers has external peripherals (Real-
(Real-time Clock, USB,
Ethernet, WiFi
WiFi,, Bluetooth etc.) connected to it and are visible outside. But an
embedded device contains few or all the peripherals inside the module, i.e. SOC
(System On Chip).
Embedded System VS General Purpose
System
Embedded System
• Microcontrollers are sometimes called embedded
microcontrollers,, which just means that they are part of
microcontrollers
an embedded system -- that is, one part of a larger
device or system.
• The majority of microcontrollers in use today are
embedded in other machinery, such as automobiles,
telephones, appliances, and peripherals for computer
systems. These are called embedded system.
system.
• Typical input and output devices include switches, relay,
solenoids, LEDs, small or custom LCD displays, radio
frequency devices, and sensors for data such as
temperature, humidity, light level etc.
• Embedded systems usually have no keyboard, screen,
disks, printers, or other recognizable I/O devices of a
personal computer, and may lack human interaction
devices of any kind.
kind. Real inside microcontroller
Examples of Embedded System
• Consumer Electronic : DVD player, hi-hi-fi, TV, air-
air-conditioner, washing machine etc.
• Medical Monitoring Devices : ECG (electrocardiogram), blood pump, blood pressure
meter, etc.
• Security System : Alarm, remote sueveilance, smart card + reader etc.
• Closed Loop Process Control : Motor speed control, robot, SCADA (supervisory
control & acquisition) etc.
• Personal Computing : Keyboard, printer, USB hub, SCSI HD, energy management etc.
• Automotive : Ignition control, A/C, Automatic transmission, anti-anti-lock brake system
(ABS), active suspension, etc
• Military : Missile, torpedo, ejection seat, etc
• Communications : Handphone, modem, radio, radar, satelite etc.
9 9
Microcontroller Parts
Microcontroller Parts: CPU
- CPU
CPU:: Central Processing Unit “Smart part” of the computer that processes
data and makes decisions Has all the parts of a normal microprocessor
- CPU is the brain of a microcontroller. CPU is responsible for fetching the
instruction, decodes it, then finally executed. CPU connects every part of a
microcontroller into a single system. The primary function of CPU is fetching
and decoding instructions. The instruction fetched from program memory
must be decoded by the CPU.
CPU.
Microcontroller Parts: Memory
• The function of memory in a microcontroller is the same as a microprocessor.
It is used to store data and program. A microcontroller usually has a certain
amount of RAM and ROM (EEPROM, EPROM, etc etc)) or flash memories for
storing program source codes.
codes.
- RAM – Random Access Memory – Storing data while microcontroller is
running
- ROM – Read Only Memory – Store bootup data information
EEPROM or EPROM – Persistent storage of data parameters that can be
rewritten
Microcontroller Parts: Input
Input// Output Ports
- I/O
Methods to interact with the world outside the microcontroller : A typical
CPU takes up only a small portion of the actual silicon real estate of a
microcontroller leaving additional space for other features.
- Ex
Ex::
• A/D – Analog to Digital Converter
• Temperature Sensor
• Display controller
• Timing circuits
• Communication circuits
• Parallel, Serial, Ethernet
Microcontroller Parts: Timers/counters
This is the one of the useful function of a microcontroller. A microcontroller may
have more than one timer and counters. The timers and counters provide all
timing and counting functions inside the microcontroller. The major operations of
this section are performed clock functions, modulations, pulse generations,
frequency measuring, making oscillations, etc. This also can be used for counting
external pulses.
Microcontroller Parts: ADC/DAC
• Analog to Digital Converter (ADC)
ADC converters are used for converting the analog signal to digital form. The input signal
in this converter should be in analog form (e.g. sensor output) and the output from this
unit is in digital form. The digital output can be used for various digital applications (e.g.
measurement devices).
devices).
• Digital to Analog Converter (DAC)
DAC perform reversal operation of ADC conversion.
conversion. DAC converts the digital signal into
analog format. It usually used for controlling analog devices like DC motors, various
drives, etc.
etc.
Microcontroller Parts
• Interrupt control
• The interrupt control used for providing interrupt (delay) for a working
program. The interrupt may be external (activated by using interrupt pin) or
internal (by using interrupt instruction during programming).
programming).
• Special functioning block
• Some microcontrollers used only for some special applications (e.g. space
systems and robotics) these controllers containing additional ports to perform
such special operations. This considered as special functioning block.
Advantages of Microcontrollers
a) Microcontrollers act as a microcomputer without any digital parts.
b) As the higher integration inside microcontroller reduces cost and
size of the system.
c) Usage of a microcontroller is simple, easy to troubleshoot and
system maintaining.
d) Most of the pins are programmable by the user for performing
different functions.
e) Easily interface additional RAM, ROM,I/O ports.
f) Low time required for performing operations.
Disadvantages of Microcontrollers
a) Only perform a limited number of executions simultaneously.
b) Mostly used in micro
micro-- equipments
equipments..
c) Cannot interface high power devices directly.
Microprocessors Microcontrollers
1 It is only a general purpose computer It is a microcomputer itself
CPU
2 Memory, I/O ports, timers, interrupts All are integrated inside the microcontroller
are not available inside the chip chip
3 This must have many additional digital Can function as a microcomputer without any
components to perform its operation additional components.
4 Systems become bulkier and expensive. Make the system simple, economic and
compact
5 Very few pins are programmable Most of the pins are programmable
6 Widely Used in modern PC and laptops widely in small control systems
E.g. INTEL 8086,INTEL Pentium series INTEL8051,89960,PIC16F877
Interface
• An interface device (IDF) is a hardware component or system of components that
allows a human being to interact with a computer, a telephone system, or other
electronic information system.
Ex:
An audio interface is a piece of hardware that expands and improves the sonic
capabilities of a computer. Some audio interfaces give you the ability to connect
professional microphones, instruments and other kinds of signals to a computer, and
output a variety of signals as well.
Interface
Interface
Microcontroller Types
There are a differences within the same
family
The appropriate microcontrollers
selection
• The microcontroller pins that we need
• The type of interfaces we need
• The memory size we need
The appropriate microcontrollers
selection
Data sheet
A datasheet, data sheet, or spec sheet is a document that summarizes
the performance and other technical characteristics of a product,
machine, component, material, a subsystem or software in sufficient
Data sheet
Data sheet
Data sheet
Why use a microcontroller?
- Reduce chip count
- Many applications do not require as much computing power
- Reduced power consumption
- Reduced design cost
In fact, industry sells 10 times as many microcontrollers as microprocessors
Applications
• You can find microcontrollers in all kinds of electronic devices these days.
Any device that measures, stores, controls, calculates, or displays
information must have a microcontroller chip inside. The largest single use
for microcontrollers is in the automobile industry (microcontrollers widely
used for controlling engines and power controls in automobiles). You can
also find microcontrollers inside keyboards, mouse, modems, printers, and
other peripherals. In test equipment, microcontrollers make it easy to add
features such as the ability to store measurements, to create and store user
routines, and to display messages and waveforms. Consumer products that
use microcontrollers include digital camcorders, optical players, LCD/LED
display units, etc. And these are just a few examples.
examples.
Applications
Some basic applications of a microcontroller are given below.
a) Used in biomedical instruments.
b) Widely used in communication systems.
c) Used as a peripheral controller in PC.
d) Used in robotics.
e) Used in automobile fields.
fields.
Programming Languages
• Machine Code
• Low level language - Assembly
• High level language - C, C++, Java
• Application level language - Visual Basic, scripts, Access
Machine code
Machine code or machine language is a set of instructions executed directly by a
computer's central processing unit (CPU). Each instruction performs a very specific
task, such as a load, a jump, or an ALU operation on a unit of data in a CPU register
or memory. Every program directly executed by a CPU is made up of a series of
such instructions.
Low level Language: Assembly
Languages
High level language
Embedded Programming
- Key Points in Embedded Programming
• Code Speed - Timing constraints, limited proc. power
• Code Size - Limited memory, power, physical space
Embedded programming
- Assembly in embedded programming .
• High speed, low code size
• However, difficult to do a large project in assembly
- C in embedded programming .
• Fairly efficient
• Provides an additional level above assembly programming
• Supports access to I/O
• Ease of management of large embedded projects
Programs used with microcontroller
Embedded Systems any Where
Thank