Professional Documents
Culture Documents
Tut3 Architecture
Tut3 Architecture
Architecture
PIC16F877A
1
SESSION'S AGENDA
2
TYPES OF ARCHITECTURES
3
VON NEUMANN
The design has a single memory bank for storing both the
program and data.
4
VON NEUMANN ARCHITECTURE
Single bus
Princeton architecture
5
HARVARD ARCHITECTURE
Separate memory banks for program and data storage.
6
HARVARD ARCHITECTURE
Program address bus
7
VON NEUMANN Vs HARVARD
9
Advantages of Harvard architecture
This feature is , what is used in the PIC MCUs makes it well suited
Cycle 2:
- Read Data out of RAM and put into Acc..
Harvard
Cycle -1 :
- Complete Previous instruction
- Read the next instruction "move Acc,Reg" instruction
Cycle 1 :
- Execute "move Acc, Reg" instruction
- Read next instruction
11
Instruction Pipe lining
Pre-Fetched Instruction Executing Instruction
movlw 0x05 -
Instruction Cycles
Example Program T0
2 movwf REG1
3 call SUB1
4 addwf REG2
Example Program T0 T1
3 call SUB1
4 addwf REG2
Example Program T0 T1 T2
4 addwf REG2
In the third instruction cycle, the instruction fetched in
the second cycle is executed and the next instruction is
fetched.
51 SUB1 movf PORTB,w At this point, it becomes clear that because of the pipe
52 return lining, each instruction (except the first) effectively takes
only one cycle to execute because each instruction has
53 SUB2 movf PORTC,w already been fetched and is ready to execute by the time
54 return the previous instruction has finished executing.
Instruction Pipe lining
Pre-Fetched Instruction Executing Instruction
Example Program T0 T1 T2 T3
Instruction Decoder:
Part of the electronics which "recognizes" different
program instructions and directs the other circuits
accordingly.
16
SOME BASIC TERMS USED!!!
Read Only Memory (ROM):
ROM is the memory which stores the program to be
executed. It can be either internal (on-chip) or external
(interfaced) with respect to the Micro controller and the
data stored cannot be changed during runtime.
EEPROM Memory:
EEPROM is a special kind of memory that can be changed
during runtime and also the data is retained after power is
17
off and it is not available with all MCUs.
SOME BASIC TERMS USED!!!
SFR Registers:
Special Function Registers are special elements of RAM with
their purpose predefined and also named by the
manufacturer. Each and every SFR controls a certain
subsystem of MCU.
Program Counter:
This is the "engine" which starts the program and points to the
memory address of the instruction to be executed.
Immediately upon execution, value of PC increments by 1.
I/O Ports:
To be of any practical use, Micro Controller needs to be
connected to other electronics and to the environment. For
this purpose, pins are provided on input/output -- I/O ports 18
SOME BASIC TERMS USED!!!
Oscillator:
Stable waveform provided by oscillator allows
synchronous functioning of all parts of MCU. The
oscillator frequency is mostly stabilized using a quartz-
crystal or a ceramic resonator though it can also work
without an element for stabilizing frequency (as RC
oscillator).
Bit:
A data which can be of either zero or one (binary digit).
Byte:
Collection of 8 bits add-up to form a byte of data.
Word in our case is 14bit wide 19
SOME BASIC TERMS USED!!!
Set To force a bit/register to a value of logic ‘1’.
Clear To force a bit/register to a value of logic ‘0’
Reset 1) To force a register/bit to its default state.
2) A condition in which the device places itself
after a device reset occurs.
Instruction cycle
The events for an instruction to execute. There are
four events which can generally be described as:
Decode, Read, Execute, and Write.
Four external clocks (Tosc) make one instruction
cycle (TCY).
20
BLOCK DIAGRAM
OF
PIC16F877A
21
22
PORTS A…E
SUPPORTING
FUNCTIONS CPU
BASIC FUNCTIONAL BLOCK
24
About the Architecture
Stack Pointer
The stack pointer is present in memory organization, it is used to store
the address of the program in LIFO method, the detail description
about the SP(Stack Pointer) will come in memory Organization.
26
TIMER 0
The Timer0 module has the following features:
• 8-bit timer/counter
• Readable and writeable
TIMER 1
The Timer1 module is a 16-bit timer/counter .
The TMR1 Register pair (TMR1H:TMR1L) increments from
0000h to FFFFh and rolls over to 0000h.
Timer1 can operate in one of three modes:
• As a synchronous timer
• As a synchronous counter
• As an asynchronous counter
Timer2
Timer 2 is an 8-bit timer for pulse width modulation mode of
operation
Synchronous Serial Port (SSP) module
The I2C bus is a two line, multi-master, multi-slave network interface with
collision detection. Up to 128 devices can exist on the network and they
can be spread out over 10 meters.
The A/D converter has a unique feature of being able to operate while
the device is in Sleep mode.
COMPARATOR MODULE
The comparator module contains two analog comparators.
When the analog input at VIN+ is less than the analog input
When an external event occurs e.g. a signal transition from low to high ,the value
of both Timer1 registers is stored in the CCP registers.
Stored values determine the time t when the event has occurred
Compare
Compares the Timer1 value to the CCP value and generates an output signal when
a match occurs which helps in generating an output at a specific time.
One internal use of this mode is to send a 'special event trigger signal' to start an
ADC conversion - this would be useful in a data logger.
PWM has many uses from controlling the speed of a DC motor , generating an
analogue signal or controlling the brightness of a bulb.
The basic principle is that the output is fully on or off but by varying the
percentage of time that the output is on then the average current delivered to the
load can be controlled.
.
SUPPORING FUNCTIONAL BLOCKS
WATCH DOG TIMER (WDT)
40
Power-up Timer (PWRT)
If the Brown-Out Detect Enable bit (BODEN) is set, a PSU glitch of longer than
about 100 μs will cause the device to be held in reset until the supply recovers,
and then wait for the power-up timer to time out, before restarting.
43
(P)BOR – Brown Out Reset
Holds PIC® MCU in reset until ~72ms after VDD rises back above threshold
VDD
BVDD
72ms
Internal
Reset
VDD
BVDD
72ms
Internal
Reset <72ms
VDD
BVDD
72ms
Internal
Reset
WDT
WORKING OF A MICROCONTROLLER
OSC
ROM PC
TIMERS Inst decoder
RAM CPU
R
SF CONTROL
Data
W REG
A/D
I/O PORT
1 0 EEPROM
EEPROM
PIN 7 PIN 3
TYPICAL INTERFACING OF PERIPHIRALS
LOW VOLTAGE PROGRAMMING
Use of this mode has the disadvantage that RB3 is not then available
for general I/O functions during normal operation.
IN-CIRCUIT DEBUGGING
51
END OF TUTORIAL 3
52
CISC
CISC stands for "Complex Instruction Set Computer"
54
RISC Vs CISC
RISC CISC
EEPROM memories are usually very slow. An EEPROM chip is much costlier than
an EPROM chip.
Flash EEPROM
Flash EEPROM, a version of EEPROM memory, has become popular in
microcontroller applications and is used to store the user program. Flash
EEPROM is nonvolatile and usually very fast. The data can be erased and then
reprogrammed using a suitable programming device. Some microcontrollers have
only 1K flash EEPROM while others
have 32K or more.
MCU normally operate at 0 to 5V voltage levels, the RS232 signals must be
converted to 0 to 5V when input to a microcontroller. Similarly, the output of
the microcontroller must be converted to 12V before sending to the receiving
RS232 device. The voltage conversion is usually carried out with RS232
converter chips, such as the MAX232, manufactured by Maxim Inc.