Professional Documents
Culture Documents
Week 1
Microcontroller PIC16F84
Chapter 1 Outline
Review on Microprocessor Systems Microprocessor Vs Microcontroller The Microcontroller The PIC 16F84 Microcontroller Clock Generator Reset Central Processing Unit (CPU) Memory Organization Ports Timer Bus System
Chessda
Microprocessor System The P system components include a CPU, RAM, ROM and I/O ports Its interconnections comprise an address bus, a data bus and control lines These buses are required to handle the data transfer between the CPU, memory and ports
Chessda
ROM
EEPROM
Microprocessor
RAM
Serial I/O Input and output ports Parallel I/O Timer PWM
A/D
Analog I/O
D/A
Microprocessor System (Cont..) Program execution- The ROM and RAM contain program and data in
numbered locations. - Each instruction and operand are stored in sequential locations. - The program instruction codes are fetched into the CPU and decoded.
Chessda
Chessda
Data Processing
Data register 7 Result 8
Chessda
PC Engineering Applications
Can be used as a standard hardware platform in a variety of engineering systems by fitting special interfacing hardware and programming the PC to control an external system through I/O. increasingly used in manufacturing systems; control a machine tool, robot or assembly system.
Chessda
Chessda
The Microcontroller
The microprocessor can provide, in a simplified form, all the main elements of the conventional microprocessor system on one chip. Less complex applications can be designed and built quickly and cheaply. A working system can consist of a microcontroller chip and just a few external components for feeding data in and out, and generating the clock.
Chessda
A Microcontroller Applications
- Used to control a small system. - calculator, message display, electronic lock or similar applications & etc.
Chessda
RAM
Analog In
CPU Core
A/D
Serial I/O
Parallel I/O
Microcontroller
PWM
Analog Out
Chessda
Programming a Microcontroller
- Normally have ROM program memory, into which the program must be loaded before the chip is placed in the application circuit. - The program is written and converted to machine code in the host, and downloaded via a serial data link. - The chip is then removed from the programming unit and inserted into the application hardware.
Chessda
Chessda
Chessda
Microcontroller Applications
Automotive industries Controlling home appliances Controlling industrial instruments Remote sensors Electric door locks Safety devices Smart cards Many more.
Chessda
Microcontroller Vs Microprocessor
ROM EEPROM
Microprocessor
RAM
Serial I/O Input and output ports Parallel I/O Timer PWM
A/D
Analog I/O
D/A
Microprocessor-based system
ROM
EEPROM
CPU Core
Analog In
A/D
Microcontroller-based system
Filter Digital PWM
Timer
PWM
Microcontroller
Analog Out
Chessda
Hardware Architecture
Single-chip CPU High RAM-ROM ratio External components are required to implement interrupt, timer and I/O operations
Used as CPU in computer systems for general processing Powering and processing intensive instructions More suitable for large volume data handlings AND, OR, XOR operations at bit level is less easy
Single-chip computer High ROM-RAM ratio Built-in interrupt, timer and I/O devices
Used in control-oriented systems requiring minimum components Simple and compact instructions More suitable for single-bit I/O operations AND, OR, XOR operations at bit level is easy
Chessda
Applications
Microprocessor
Microcontroller Low density Less PCB area Low cost Specific Architecture Low power consumption
high density higher PCB area high cost Flexible high power consumption
Chessda
The PIC 16F84 Microcontroller PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. It is belongs to a mid-range family of the PICmicro microcontroller devices.
Chessda
PIC Microcontroller
Chessda
PIC Microcontroller
Free-run Counter
CPU
PORT A PORT B
Chessda
Chessda
Chessda
XT Oscillator
Chessda
RC Oscillator
In applications where great time precision is not necessary, RC oscillator offers additional savings during purchase Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature.
Chessda
Reset
Reset is used for putting the microcontroller into a 'known' condition. When microcontroller behave inaccurately under certain undesirable conditions, in order to continue its proper functioning it has to be reset meaning all register would be placed in a starting position.
Chessda
Reset (Cont..)
Microcontroller PIC16F84 knows several sources of resets: Reset during power on, POR (Power-On Reset) Reset during regular work by bringing logical zero to MCLR microcontroller's pin. Reset during SLEEP regime Reset at watchdog timer (WDT) overflow Reset during at WDT overflow during SLEEP work regime
Chessda
Chessda
ALU
User-Visible Registers
Accumulator Address Register Data Register
CU
Flag Register .
CPU
Chessda
Chessda
Chessda
Chessda
Memory Organization
PIC16F84 has two separate memory blocks, one for data and the other for program. EEPROM memory with GPR and SFR register in RAM memory make up the data block. FLASH memory make up the program block.
Chessda
Program Memory
Program memory has been carried out in FLASH technology which makes it possible to program a microcontroller many times before it's installed into a device. The size of program memory is 1024 locations with 14 bits width where locations zero and four are reserved for reset and interrupt vector.
Chessda
Data Memory
Data memory consists of EEPROM and RAM memories. EEPROM memory consists of 64 eight bit locations whose contents is not lost during loosing of power supply. EEPROM is not directly addressable, but is accessed indirectly through EEADR and EEDATA registers RAM memory for data occupies space on a memory map from location 0x0C to 0x4F which comes to 68 locations.
Chessda
Chessda
Chessda
Chessda
Chessda
Chessda
Chessda
Chessda
Chessda
Program Counter
Program counter (PC) is a 13-bit register that contains the address of the instruction being executed. It is physically carried out as a combination of a 5-bit register PCLATH for the five higher bits of the address, and the 8-bit register PCL for the lower 8 bits of the address.
Chessda
Stack
PIC16F84 has a 13-bit stack with 8 levels, or in other words, a group of 8 memory locations, 13 bits wide, with special purpose. Its basic role is to keep the value of program counter after a jump from the main program to an address of a subprogram. In order for a program to know how to go back to the point where it started from, it has to return the value of a program counter from a stack
Chessda
Ports
Port is a group of pins on a microcontroller which can be accessed simultaneously or on which we can set the desired combination of zeros and ones. Physically, port is a register inside a microcontroller which is connected by wires to a pins. Port represent physical connection of CPU and outside world.
Chessda
Ports (Cont..)
Microcontroller uses them in order to monitor or control other components or devices. All port pins can be designated as input or output, according to the needs of the device thats being developed.
Chessda
Chessda
Chessda
Chessda
Chessda
Timer
Physically, timer is a register whose value is continually increasing and reset to 0 when its value has reach the maximum count value.
Chessda
Timer
(cont..)
The Timer0 module of PIC16F84 timer/counter has the following features: 8-bit timer/counter Readable and writable Internal or external clock select Edge select for external clock 8-bit software programmable prescaler Interrupt-on-overflow from FFh to 00h
Chessda
Timer
(cont..)
Chessda
Chessda
Memory System
RAM (Random Access Memory) a general purpose memory which usually stores user data. RAM is volatile. ROM (Read Only Memory) usually holds program of fixed user data. ROM are programmed at the factory and their contents cannot be changed by the user. ROM are only useful if we have developed program and wish to order several thousand copies of it.
Chessda
Chessda
Chessda
Chessda
Bus System
Bus system is a collection of wires carrying information within a computer system. There are three types of system busses: address, data and control busses. Address Busses are wires that carry the CPUgenerated address signals out to memory and to I/O devices. It is an uni-directional. The size of the memory space that a microprocessor can access depends on the number of address lines.
Chessda
20
24 32
Chessda
Chessda
Chessda
I/O Modules
I/O modules provide interface between the computer system and the real world. An external device connected to an I/O modules is often referred to as a peripheral device. Three broad classes of I/O devices are:
Human-readable I/Os: suitable for communication with the user. E.g. Monitor, keyboard, mouse, joystick, video display terminals, printer, scanner, microphone and speaker
Chessda
Chessda