0% found this document useful (0 votes)
46 views16 pages

Micro Unit 3 Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views16 pages

Micro Unit 3 Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

UNIT – III: PIC 18FXXX Microcontroller Architecture

Q. 1 List Features of the PIC18 microcontroller


• It uses RISC architecture
• It has 8-bit CPU,16 bit instructions
• 2 MB program memory space
• 256 bytes to 1KB of data EEPROM
• Up to 3968 bytes of on-chip SRAM
• 4 KB to 128KB flash program memory
• 4 Timers/ Counters,( 4 Timers)
• 5 ports A[6], B,C,D[8], E[4] =35 IO lines (USB)
• PWM, real-time interrupt, and watchdog timer
• Serial communication interfaces: SCI, SPI, I2C
• Supports for CCP Mode
• Background debug mode (BDM)
• 10-bit A/D converter
• Instruction pipelining
• Operates at up to 40 MHz crystal oscillator.
• Programmable Brown out reset module, Power On Reset(POR), Power-saving mode

Q. 2 Explain Criteria for Choosing Microcontroller


While selecting Microcontroller series for particular application following criteria has to be considered
1. Data Handling Capacity- Bits, Nibble Bytes, Words, Double words, Quad Words etc.
2. Speed --- Depends on Clock
3. Amount of RAM/ ROM/ EPROM/ Flash/ Static
4. Number of I/O pins, Timers – All SFRS
5. Power consumption – Based on the modes
6. Packaging – 40 PIN DIP,/ QFP/ other– Important – Space, assembly, Prototyping the end Product
7. Added features like ADC/ DAC/ CCP, Bus support like CAN, SPI, I2C, USB.
8. Watchdog timer, Timer modes, Data EEPROM etc.
9. Easy to upgrade --Higher Performances or low power operations
10. Availability of Software and Hardware Development Tools like
1. Assembler
2. Compilers – Code efficient C language
3. Debuggers
4. Emulators
5. Technical Support
11. Wide Availability and Reliable Sources of Microcontrollers

Mrs. Trupti Thite, TE ENTC Microcontroller Page 1


Q. 3 compare various PIC series architectures.
All PIC series architectures can be compared according to following features,
Data Bus Width
Program Memory
Data Memory
No. of I/O Pins used for Interfacing
Enhanced Modes of Operation (CCP, PWM, ISP)
Modes of Serial Communications (MSSP) – I2C and SPI
Timers used for Setting Delay
Most Important Special features

Mrs. Trupti Thite, TE ENTC Microcontroller Page 2


Q 4. Draw and explain PIC 18F architecture

PIC microcontrollers are designed using the Harvard Architecture which includes:
Microprocessor unit (MPU)
Program memory for instructions
Data memory for data
I/O ports
Support devices such as timers, ADC etc.
Support for serial communication using Various Buses like SPI, I2C

MCU unit includes: Arithmetic Logic Unit (ALU), Registers, and Control Unit
Arithmetic Logic Unit (ALU)
• WREG (8)– working register (Accumulator)
• Status register that stores flags
• Instruction decoder – when the instruction is fetched it goes into the ID

The CPU fetches instructions from memory, decodes them, and passes them to the ALU for execution.
• The arithmetic logic unit (ALU) is responsible for adding, subtracting, shifting and performing logical
operations.
The ALU operates in conjunction with:
– A general purpose register called W register
– And f register that can be any location in data location
Control Unit:
– Provides timing and control signals to various Read and Write operations
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


Mrs. Trupti Thite, TE ENTC Microcontroller Page 3
Data bus: 16-bit instruction/data bus for program memory and 8-bit data bus for data memory

I/O ports:
The series of PIC18 consists of five ports such as Port A, Port B, Port C, Port D & Port E. These ports
are used to connect digital Input output Devices
Timers
PIC microcontroller has four timer/counters wherein the one 8-bit timer and the remaining timers have
the choice to select 8 or 16-bit mode. Timers are used for generating accuracy actions, for example,
creating specific time delays between two operations.
ADC
The main intention of this analog to digital converter is to convert analog voltage values to digital
voltage values. The operation of the analog to digital converter is controlled by ADCON0 and ADCON1
special registers.
CCP module
The name CCP module stands for capture/compare/PWM where it works in three modes such as capture
mode, compare mode and PWM mode
Serial Communication
Serial communication is the method of transferring data one bit at a time sequentially over a
communication channel. PIC 18 has SPI, I2C and USART protocol for serial communication.

Q 5. Draw and Explain Program Memory map of PIC18Fxxx.

 Each PIC18F member has a 21-bit program counter PC (21 bit). It is used by CPU to point to the
address of next instruction to be executed from ROM.
 A 21-bit program counter is capable of addressing the 2Mbyte program memory space
1FFFFF=221=2M
 User memory space on the PIC18 microcontroller is 00000H to 7FFFH. Accessing a nonexistent
memory location (8000H to 1FFFFFH) will cause a read of all 0s.
 The reset vector where the program starts after a reset is at address 0000H. Addresses 0008H and
0018H are reserved for the vectors of high-priority and low-priority interrupts, respectively, and
interrupt service routines must be written to start at one of these locations.
 The PIC18F microcontroller has a 31-entry stack that is used to hold the return addresses for
subroutine calls and interrupt processing. The stack is controlled by a 5-bit stack pointer, which is
initialized to 00000 after a reset.
 PIC18F452 each have 32 Kbytes of FLASH memory. This means that it can store up to 16K of
single word instructions Total of word data size= 32K*16

The program memory map is shown below

Mrs. Trupti Thite, TE ENTC Microcontroller Page 4


Q 6. Draw and Explain Data Memory map of PIC18Fxxx

 Data Memory is also called as File Register


 The data memory address bus is 12 bits, with the capability of addressing up to 4 KB.
 The memory in general consists of 16 banks, each of 256 bytes.
 Bank switching is done automatically when using a high-level language compiler, and thus the user need
not worry about selecting memory banks during programming.

 There are two types of registers in the data memory, the General Purpose Register (GPRs) and the
Special function Registers (SFRs).
 General purpose registers (GPRs) are used to hold dynamic data during program execution.
 SFR has dedicated functions Such as ALU Status, Timers, Serial communication. ADC, I/O Ports etc.

Mrs. Trupti Thite, TE ENTC Microcontroller Page 5


 Bank Select Register (BSR) is used to select the bank.

PIC18 implements the access bank to reduce the problem caused by bank switching.
It is the default bank when we power up the PIC18
Access bank is formed using 128 bytes from GPR 00h to 7Fh and 128 bytes from SFR F80h to FFFh

The data memory map of the 18F microcontroller is shown below.

Mrs. Trupti Thite, TE ENTC Microcontroller Page 6


Q 7. Explain working register (WREG) & status register in PIC18.

• Working Register (W): It is 8 bit Temporary holding register. Called as Accumulator.


 It Cannot be access Directly
 It is used by many instructions as source of an operand.
 It is used as Destination for the result of instruction execution

• status register: It is an 8-bit register referred as flag registers and all are conditional

• C (Carry Flag)
– Set when an addition or subtraction generates a carry out of B7 Bits (unsigned Nos.)
• DC (Digit Carry Flag) (Half Carry)
– Set when carry generated from B3 to B4 in an BCD arithmetic operation ( Addition or
Subtraction)
• Z (Zero Flag)
– It reflects the result of arithmetic or logic operations. If result =0, Z=1 and if result ≠0, Z=0
• OV (Overflow Flag)
– Set when result of an operation of signed numbers goes beyond 7-bits- used to represent the
errors { carry from B6 to B7 but no carry out of B7[C=0];Carry out from B7[C=1]}
• N (Negative Flag)
– Binary representation of signed No. It is the reflection of the result of an arithmetic/logic
Operation if Result B7=0 , No. is Positive, if Result B7=1 , No. is negative

Q 7. What are various oscillator options? How they can be selected using config register

Essentially, there are three clock sources for The PIC microcontroller to operate in different modes of operation:
Primary oscillators: The primary oscillators include the External Crystal and Resonator modes
Secondary oscillators: The secondary oscillators are those external sources not connected to the OSC1 or
OSC2 pins.
Internal oscillator block: In addition to being a primary clock source, the internal oscillator block is available
as a power-managed mode clock source.

Mrs. Trupti Thite, TE ENTC Microcontroller Page 7


CONFIG1H Register is used to set the clock oscillator for smooth function in PIC with internal or external
crystal for low power consumption

Mrs. Trupti Thite, TE ENTC Microcontroller Page 8


The Explanation of above different oscillator options is given in below table

Q 8. Explain BOD and Power Down modes of PIC18Fxxx.

BOD/BOR
Mostly all microcontrollers have built in Brown-out detection (BOD) or Brown out reset(BOR) circuit,
which monitors supply voltage level during operation. BOD circuit is nothing more than comparator, which
compares supply voltage to a fixed trigger level.

CONFIG2L Register is used for This Purpose


Used to provide stable voltage and clock frequency during reset function, PWRT provides fixed delay for
stabilizing the voltage source at required value.
When power source provided to Microcontroller fluctuates, it causes CPU malfunction. This BOR provision
allows to set minimum voltage and CPU will go into reset state and stops all activities if supply voltage falls
below set voltage.

Power Down modes/ of power-managed modes of PIC18Fxxx


Mrs. Trupti Thite, TE ENTC Microcontroller Page 9
There are three categories of power-managed modes:
• Run modes
In the Run modes, clocks to both the core and peripherals are active
• Idle modes
The Idle modes allow the controller's CPU to be selectively shut down while the peripherals continue to
operate. Selecting a particular idle mode allows users to further manage power consumption.
• Sleep mode
Sleep mode does not use a clock source

 Selecting a power-managed mode requires two decisions: if the CPU is to be clocked or not and the
Selection of a clock source
 Switching from one power-managed mode to another begins by loading the OSCCON register.
 The SCS1:SCS0 bits select the clock source and determine which Run or Idle mode is to be used

Following Table explains how particular power down mode will be selected

Q 9. Give Details about Watch Dog Timers

Watch dog timer is Hardware used in PIC microcontroller .This Timer force Microcontroller into reset state
when system is hang or out of control due to execution of incorrect code
CONFIG2H register is Used for Watch dog Timer

This timer is used to prevent a system from going into infinite loop due to software bug

Q 9. Give Brief summary of Peripheral support


Mrs. Trupti Thite, TE ENTC Microcontroller Page 10
The PIC 18FXXXX has the following peripherals:
 Data ports:
A (7-Bits)
B, C and D (8-Bits)
E (4- bits)
 Counter/Timer modules.
 Modules 0,2 (8-Bits)
Modules 1,3 (16-Bits)
 CCP Modules.
 I2C/SPI serial port.
 USART port.
 ADC 10-bits 13 Channel
 EEPROM 256 Bytes

Mrs. Trupti Thite, TE ENTC Microcontroller Page 11


Q 10. PIC Instruction set (In question paper any instruction from below instruction can
be asked

In Instruction Following notations are used

• F: File Register (or RAM)


• L: literal=8-bit constant
• W:Working Register

In Operand Following notations are used

• F: File Register (or RAM)


• a:Access Bank
• d:destination operand
• n: Memory address
• b:Bit

Mrs. Trupti Thite, TE ENTC Microcontroller Page 12


Mrs. Trupti Thite, TE ENTC Microcontroller Page 13
Mrs. Trupti Thite, TE ENTC Microcontroller Page 14
Mrs. Trupti Thite, TE ENTC Microcontroller Page 15
Mrs. Trupti Thite, TE ENTC Microcontroller Page 16

You might also like