Architecture OF MC-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

PIC® Micro controllers

Architecture-1

*
Contents
•Introduction
•Applications
•Microchip’s position
•Elements of Digital Controller
•Pin Diagram
•Internal architecture
•Simplified file register map
•I/O pin operation
•Core registers
Introduction
• The term PIC or Peripheral Interface
Controller, has been coined by Microchip
Technology Inc.

• Low-end range, mid-range and high end range


of controllers.

*
PIC Architecture: Background

• We’re used to the Von-Neuman Architecture

• Used in: 80X86 (PCs), 8051, 68HC11, etc.)


• Only one bus between CPU and memory
• RAM and program memory share the same bus
and the same memory, and so must have the
same bit width
• Bottleneck: Getting instructions interferes with
accessing RAM
*
Philosophy of PIC Architecture
• Embedded processing is pervasive
• Electronic intelligence in is everyday products

• Company Philosophy
– Have products that fit the problem
– Many systems can be automated using 8-bit
microcontrollers
– Much of product line is 8-bit

*
Some typical applications
• Automotive air bag systems
• Remote control
• Handheld tools
• Appliances – coffee pot, mixer, stove,
refrigerator, dish washer, washer, dryer
• Major home systems – heating and cooling
• Cordless phones and cell phones
• Security systems
• TV, DVD player/recorder, DVR, PVR
• Sound system

*
Come in 4-bit through 32-bit
• 4-bit
– Very inexpensive
• 8-bit
– Still very cheap – often ~$1.00 per chip
• 16 and 32 bit
– Priced at $6.00 to 12.00 each
• Evaluation of requirements, chip capability,
and cost come into design decision

*
Typical automotive use
• Engine control – 32-bit microcontroller
– Fuel flow, fuel mixture, valve timing, throttle body
opening, spark timing
• Transmission control –16-bit microcontroller
• Audio system – 16-bit
• Antilock braking – 16-bit
• Up to fifty 8-bit microcontrollers for functions of
– Wiper control
– Electric Mirrors
– Air Bags

*
Automotive today continued
• Up to fifty 8-bit microcontrollers for functions of
– Wiper control
– Electric Mirrors
– Air Bags
– Fuel pump
– Speedometer
– Security system
– Climate control system
– Po er indo s …..

*
Microchip’s position

*
PIC architecture is a Har ard architecture
• The Harvard Architecture

*
Elements of a digital controller

Input Output
User input Peripherals CPU Peripherals User output

Central
Processing
ROM Unit RAM
Program Read Only Read & Write
download Memory Memory

The microcontroller contains all these elements in one chip


Typical 16FXXX
RA0-7: Input/Output port A
RB0-7: Input/Output port B
AN0-3: Analog input port
RX: USART Asynchronous Receive
TX: USART Asynchronous Transmit
DT: Synchronous Data
CK: Synchronous Clock
CCP1: Capture In/Compare Out/PWM Out
OSC1/CLKIN: Oscillator In/External Clk In
OSC2/CLKOUT: Oscillator Out/Clock Out
MCLR: Master Clear ( Active low Reset
Vpp: Programming voltage input
T0CKI: Clock input to Timer0
T1OSO: Timer1 oscillator output
T1OSI: Timer1 oscillator input
PGD: Serial programming data
PGC: Serial programming clock
PGM: Low voltage programming input
INT: External interrupt
VDD: Positive supply
Vss : Ground reference
16F877 pin-out

The microcontroller pins have multiple functions


PIC 16F877 MCU Block diagram

Flash Program Counter


ROM (13 bits)
Program
Memory Address
8192
x 14 bits
Stack RAM
0000 – 1FFF 13 bits File
x8 Registers
Instructions levels 368
X 8 bits

Instruction Register 000-1FF


File Address

Program address

Working (W) File Select


Register Register
Literal
Arithmetic & Logic
Unit
Status bits
Status (Flag)
Op- Register
Data Bus
code
(8 bits)

EEPROM
Instruction MCU 256 bytes
Decode & control
CPU control lines
Ports, Timers
ADC, Serial I/O

Timing control

Clock Reset
Port A B C D E

Shows the main parts of the chip in simplified form


Features
• 8kB of flash program • Capture/Compare/PW
memory M modules
• 368bytes of Data • Up to 8 channels of 10-
memory Bit A/D
• 256-EEPROM data • Built-in USART for
memory serial communication
• 15 Interrupts • 5 digital I/O ports (Up
• In-circuit programming to 22 lines)
• 3 internal hardware
timers

*
PIC16F877 simplified file register map
Bank 0 (000 – 07F) Bank 1 (080 – 0FF) Bank 2 (100-180) Bank 3(180-1FF)

Addr Register Add Register Add Register Add Register


ess ress ress ress
000h Indirect 080h Indirect 100h Indirect 180h Indirect

001h Timer0 081h Option 101h Timer0 181h Option

002h PC Low 082h PC Low 102h PC Low 182h PC Low

003h Status Reg 083h Status Reg 103h Status Reg 183h Status Reg

004h File Select 084h File Select 104h File Select 184h File Select

005h Port A data 085h PortA 105h - 185h -


direction
006h Port B data 086h PortB 106h Port B data 186h PortB
direction direction
007h Port C data 087h PortC 107h - 187h -
direction
008h Port D data 088h PortD 108h - 188h -
direction
009h Port E data 089h PortE 109h - 189h -
direction
00Ah PC High 08A PC High 10A PC High 18A PC High
h h h
00Bh Interrupt 08B Interrupt 10B Interrupt 18B Interrupt
Control h Control h Control h Control
00Ch 20 08C 20 10C 4 18C 4 Peripheral
to Peripheral h Peripheral h Peripheral h Control
01Fh Control to Control to Control to Registers
Registers 09F Registers 10F
110 Registers
96 General 18F
190 96 General
020h 80 General 0A0 80 General
h h
h Purpose h
h Purpose
to Purpose h Purpose
06Fh Registers to Registers to Registers to Registers
0EF 16F 1EF
070h 16 Common 0F0 Accesses 170h Accesses 1F0 Accesses
h h
to Access h
h 70h – 7Fh to 70h – 7Fh h 70h – 7Fh
07Fh GPRs to 17F to
0FF h 1FF
PIC microcontroller types

Data Program Typical


Speed
MCU Pins word memory Instruction
MIPS Comment
(bits) (bytes) Set

Low pin count, small form factor,


10FXXX
=6 8 <= 512 33 x 12 bits <= 2 cheap
No EEPROM, none low power,
assembler program
Low pin count, small form factor,
12FXXX
=8 8 <= 2 KB 12 / 14 bits <= 5 cheap
EEPROM, 10-bit ADC, some low
power, assembler

16FXXX Mid-range, UART, I2C, SPI


<= 64 8 <= 14 KB 35 x 14 bits <= 5
many low power, C or assembler
program

18FXXXX
<= 100 8 <= 128 KB 75 x 16 bits <= 16 High range, CAN, USB
J series 3V supply, C program

24FXXXX 76 x 24 bits
<= 100 16 <= 128 KB = 16 Power range, 3V supply, no EEPROM,
data RAM < 8 KB, C program
I/O pin operation

Write TRIS bit Data


Direction Tri-state
Latch Output
Enable

Output Output
CPU Data Bus
Data Current
Latch Driver
Write data bit

Input
Data
Read data bit Latch

Analogue input
multiplexer

The pin can be set for input or output data transfer


I/O Ports

• PIC 16F877A has FIVE I/O Ports


• A total of 33 pins are used for I/O operations.

PORT A
• Port A is 6 bit wide and bi-directional.
• Its corresponding data direction register is TRISA.
• If TRISA port pin is set to 1,corresponding port A pin will act
as an input pin and vice versa.
• Port A is used for analog inputs.

*
Port B

• Port B is 8 bit wide and bi-directional.


• Its corresponding data direction register is
TRISB.
• If TRISB port pin is set to 1,corresponding port
B pin will act as an input pin and vice versa.
• Port B is used for Data Transmission.

*
Port C

• Port C is 8 bit wide and bi-directional.


• Its corresponding data direction register is TRISC.
• If TRISC port pin is set to 1,corresponding port C pin
will act as an input pin and vice versa.
• Port C is used for control registers(serial
communication, I2C functions, serial data transfer).

*
Port D

• Port D is 8 bit wide and bi-directional.


• Its corresponding data direction register is
TRISD.
• If TRISD port pin is set to 1,corresponding
port D pin will act as an input pin and vice
versa.
• Port D is used as Data port

*
Port E

• Port E is 3 bit wide . They are for read, write


and chip select operation.
• Each pin is individually configurable as inputs
and outputs.
• Port E is generally used for controlling
purposes.

*
Machine Cycle
T1 T2 T3 T4

Clock

Read
Instruction

Decode
Instruction

Execute
Instruction

Store Result

Oscillator circuits generate a clock signal.

*
Calculations

• A Machine cycle is the time taken for a data


transfer from or to memory/ I/O Ports.
• Machine cycle is calculated using the formula:
Clock Frequency=6.144MHz
Machine cycle frequency= 6.144 MHz /4
Hence 1 Machine cycle(Time taken for a
data transfer)= 1/T
= 4/ 6.144 MHz
= 0.651 µs
*
PIC overview

Different PICs have different on-board peripherals some


common peripherals are:
– 3 Timers (0 & 2- 8bits, 1-16 bits)
– 2 Compare/Capture/PWM Modules
– Analog to Digital Converters (ADC) (8, 10 and 12bit, 50ksps)
– Serial communications: UART (RS-232C), SPI, I2C, CAN
– Pulse Width Modulation (PWM) (10bit)
– Voltage Comparators
– Voltage Reference Modules
– MSSP – Master Synchronous Serial Port
– I2C (Master and Slave)
– SPI (Master and Slave)
– Watchdog timers, Brown out detect, LCD drivers
*
STATUS Register

TO: Time-out bit


1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT time-out occurred

PD: Power-down bit


1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
OPTION_REG Register

T0CS: TMR0 Clock Source Select bit


1 = Transition on T0CKI pin
0 = Internal instruction cycle clock (CLKOUT)

PSA: Prescaler Assignment bit


1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
Program Memory Organization
Data Memory Map

You might also like