Unit III - Architecture - MNK
Unit III - Architecture - MNK
Architecture
Prof. M. N. KAKATKAR
Syllabus
Intel’s 8051
Atmel’s AVR
Zilog’s Z8
Assemblers
Debuggers
Emulators
Ease of upgrade.
RISC vs CISC: Characteristics
RISC CISC
1. Simple Instruction taking 1 cycle 1. Complex Instruction taking multiple cycles
2. Only LOADs, STOREs access memory 2. Any Instruction. may access memory
Address
Address
Data Data
Address Data
Memory
(Program and Data)
Harvard Architecture -- RISC
Harvard Architecture:
Uses two separate memory
spaces for program instructions
and data
Improved operating bandwidth
Allows for different bus widths
Address
Address
Input Control CPU ALU Output
Program Data
Memory Memory
9 Prof. M. N. Kakatkar S.C.O.E , Pune 10/5/2024
PIC Microcontroller– General features
I/O
Memory CPU (Ports A, B & C)
Up to 10 MIPS operation
Peripheral Features:
• High current sink/source 25 mA/25 mA.
• Three external interrupt pins.
• Four Timer modules (Timer0 to Timer3).
• Timer0 module: 8-bit/16-bit timer/counter with 8-bit
programmable prescaler
• Timer1 module: 16-bit timer/counter
• Timer2 module: 8-bit timer/counter with 8-bit period
register (time base for PWM)
• Timer3 module: 16-bit timer/counter
• Secondary oscillator clock option – Timer1/Timer3
Features of IC 18F452/458 -- Peripherals
Peripheral Features:
• Capture/Compare/PWM (CCP) modules;
• CCP pins can be configured as:
• Capture input: 16-bit, max resolution 6.25 ns
• Compare: 16-bit, max resolution 100 ns (TCY)
• PWM output: PWM resolution is 1 to 10-bit
• Max. PWM freq. @:8-bit resolution = 156 kHz
10-bit resolution = 39 kHz
Features of IC 18F452/458 -- Peripherals
I/O ports
ADDLW 8-bit_data
Add 8-bit literal value into WREG and store result into
WREG.
To perform addition of 25H+34H=59 we can use
above instructions as
MOVLW 25H ; move value 25H into W
; i.e. W=25H
ADDLW 34H ; W=W+34H
; W=25H+34H=59H
File Register
Instruction Decoder
Decodes instruction in instruction register.
Decoding includes determining where its operands are
in memory, retrieving operands from memory,
allocating resources to execute the command
PIC18F – MCU and Memory
16 bit
2 MB
221
8 bit
4 KB
212
Microprocessor Unit (MCU)
It includes
ALU
Registers
Control Unit
Arithmetic Logic Unit (ALU)
Example
ADDWF F, d ; Add WREG to File (Data) Reg.
;Save result in W if d =0
;Save result in F if d = 1
Arithmetic & Logic Unit(ALU)
While the use of the BSR, with an embedded 8-bit address, allows users to
address the entire range of data memory, it also means that the user must
always ensure that the correct bank is selected.
To streamline access for the most commonly used data memory locations,
the data memory is configured with an Access Bank, which allows users to
access a mapped block of memory without specifying a BSR.
The Access Bank is used by core PIC18 instructions that include the
Access RAM bit (the ‘a’ parameter in the instruction). When ‘a’ is equal to
‘1’, the instruction uses the BSR and the 8-bit address included in the
opcode for the data memory address. When ‘a’ is ‘0’, however, the
instruction is forced to use the Access Bank address map; the current value
of the BSR is ignored entirely.
Accessing Data Memory
The machine code for a PIC18 instruction has only 8 bits
for a data memory address which needs 12 bits. The Bank
Select Register (BSR) supplies the other 4 bits.
Registers
Data Bus:
16-bit instruction/data memory for program.
8-bit data bus for data memory.
PIC18F458 –Memory Data and Address Bus
16 bit
2 MB
221
8 bit
4 KB
212
Address bus:
21-bit address bus for program memory addressing capacity: 2 MB of memory
12-bit address bus for data memory addressing capacity: 4 KB of memory
Data bus: 16-bit instruction/data bus for program memory
8-bit data bus for data memory
Flags in Status Register
N (Negative Flag)
Set when bit B7 is one as the result of an arithmetic/logic operation
OV (Overflow Flag)
Set when result of an operation of signed numbers goes beyond 7-bits
Z (Zero Flag)
Set when result of an operation is zero
DC (Digit Carry Flag) (Half Carry)
Set when carry generated from Bit3 to Bit4 in an arithmetic operation
C (Carry Flag)
Set when an addition generates a carry
PIC Registers- Program Counter
10/5/2024
1FFFFFH
PIC 18 has a stack pointer of 5 bit that can take
values from 00 to 1FH
53 Prof. M. N. Kakatkar S.C.O.E , Pune
Prof. A. V. Bankar
PIC Registers
10/5/2024
Power On Reset:
MCLR:
Pin 1 is the MCLR (Master Clear Input) pin. It is
active low and when a low pulse is applied to the
pin, the microcontroller will reset and terminate
all activities. This is often referred as power on
reset (POR)
10/5/2024
Power up Timer (PWRT):
1.The power up timer provides a fixed nominal time out ,
only on power up from the Power on reset
2.The power up timer operates on an internal RC
Oscillator
3.The chip is kept in reset as long as the PWRT is
active
4.The PWRT time delay allows Vdd to rise to an
acceptable level
5.A configuration bit PWERTEN is provided to
enable/ disable the PWRT
6.The power up time delay will vary from chip to chip
due to Vdd , Temperature and process variation
10/5/2024
Watchdog Timer:
1. Function: Watchdog timer is a device whose function is to
reset the system after a predefined timeout
2. We can use the watchdog timer to force the microcontroller
into the known state of reset when the system is hung up or
out of control due to execution of an incorrect sequence of
codes
3. To prevent a system from going into an infinite loop due to
a software bug
4. Catch the events that cause the system to hang
( These problem can happen due to corruption of the
ROM caused by a power surge, an electrically noisy
environment, or inadvertent changes to the program
counter )
Watchdog Timer:
5. The system can be put to sleep if there is no
activity, there by saving battery power , in such
applications one can use the watchdog timer to
monitor the keyboard and when there is activity
on the keyboard to awaken the system to process
the information
PIC 18 Configuration
Registers
10/5/2024
ADDLW f, d, a
ADDLW 0x30, 0, 0
ADDLW 0x30
MOVWF 0X22
Data Memory Addressing - Indirect