Escolar Documentos
Profissional Documentos
Cultura Documentos
PIC Microcontroller
Prepared by:
Ahmed Usama
References
Group Formation
• Group of 4 persons.
• Nominate a representative.
MICROCONTROLLERS
1st DAY
MICROCONTROLLERS
1st DAY
Review
What is the embedded system
Microprocessor , Microcontroller and FPGA.
Why a microcontroller is needed?
Variety of microcontrollers.
Why PIC microcontrollers?
Specificiations of PIC 16F877.
Programming PIC 16F877.
PIC 16F877 in circuit.
Application.
Review
• Digital System:
– A system that works with discrete elements of information rather
than with continuous signals as in an analog system.
– This discrete information is represented in binary form.
– Data processing is carried out by means of binary logic
elements using binary signals.
– Quantities are stored in binary storage elements (memory).
There are two primary classifications of logic circuits(System):
1. Combinational logic circuits
• Circuits of this type have outputs that are functions of the inputs
(illustrated below)
• The order in which the inputs are applied is not important.
• Combinational logic circuits have no capability for memory
Inputs Combinational
Logic Outputs = f(Inputs)
8
2. Sequential logic circuits
• Circuits of this type have outputs that are functions of both inputs
and previous outputs (illustrated below)
• Sequential circuits contain some type of memory elements. As an
example, a counter must “remember” that its previous output was 6 in
order to produce its new output 7.
Memory
• Control
• Electronic circuits
• Power Electronics
• Mechanics
• A microcontroller is a specialized form of microprocessor that is designed to
be self-sufficient and cost-effective, where a microprocessor is typically
designed to be general purpose (the kind used in a PC). Microcontrollers
are frequently found in automobiles, office machines, toys, and appliances.
• Microcontroller combines onto the same chip:
The CPU core (microprocessor),Memory (both ROM and RAM) ,Some
parallel digital I/O …
• A microcontroller is part of an embedded system, which is essentially the
(Microcontroller + whole circuit board) to perform dedicated task.
• Microcontroller incorporates features of microprocessor(CPU,ALU,Register)
along with the presence of added features like RAM, ROM, I\O ports,
counter etc.
• A microcontroller controls the operation of machine using fixed program
stored in Rom that doesn't change with lifetime
What is the difference?
• Microprocessor
• Microcontrollers
• FPGA
SO
• Microcontrollers are intelligent
electronic devices used to
control and monitor devices in
the real world
• Microcontrollers are
programmed devices.
• A program is a sequence of
instructions that tell the
microcontroller what to do.
Why a microcontroller is needed?
Sensors Controllers Actuators
Sensors Microcontrollers Actuators
Heater
Alarm
Power
Supply
Sensors Microcontrollers Actuators
Variety of microcontrollers
Architecture for computers:
Generally there are two types of architecture for computers
• CISC vs RISC
– In the early days work was done in assembly language.
Therefore CPU designers tried to make instructions that would
do as much work as possible. This design philosophy was
named Complex Instruction Set Computer (CISC).
– With the advent of higher level languages, led to Reduced
Instruction Set Computer (RISC) (Simple compiler to RISC)
(simpler assembly coding).
– PIC microcontroller use RISC because there is a perception that
RISC is faster than CISC:
– Ex: A processor with MUL and other one with only ADD.
A processor with (ADD X(i),B,C) and other (ADD,Store).
PIC Peripheral Interface Controller
• PIC SPEED
4MHz
10MHz
20MHz
33MHz
40MHz
PIC 16F877
Specificiations PIC 16F877
• 8 kbytes of FLASH Program Memory
• 368 bytes of Data Memory (RAM)
• 256 bytes of EEPROM Data Memory
• 20 MHz operating speed(200 ns instruction cycle)
• Max. 25 mA current from an output pin
• Low-power consumption
• Wide Operating Voltage: 2.0 – 5.0 V
• Timers
– Timer0: 8-bit timer/counter with 8-bit prescaler
– Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep via external crystal/clock
– Timer2: 8-bit timer/counter with 8-bit period register,prescaler and postscaler
• Capture, Compare, PWM modules
– Capture is 16-bit, max. resolution is 12.5 ns
– Compare is 16-bit, max. resolution is 200 ns
– PWM max. resolution is 10-bit
• 10-bit multi-channel A-to-D Converter
• I2C (Inter IC)Bus
• USART for Serial Communication
• 5 I/O Ports: A, B, C, D, and E (33 input or output pins)
Programming PIC 16F877
Languages
Parallel port
•Assembly
Serial port
•BASIC
USB port
•C
•Code Flow
Pic Basic Pro
• C-Language
• Assembly
• BASIC
Minimum circuitry for
PIC16F877
• Power Supply
• Clock generation
• Reset
PIC 16F877
PIC 16F877
PIC 16F877
Minimum circuitry for PIC16F877
TRISB("TRI-State Enable" registers for port b
One register used to define if the B is set input or output
mode of each bit (1 for an input; 0 for an output).