You are on page 1of 66



Dr.Y.Narasimha Murthy Ph.D

Do you Know this gentleman ???..

• None other than Steve Sanghi, the chairman,
president and CEO of Microchip Technology
• Sanghi moved from India to U.S. to pursue a
Master’s degree at the University of
Massachusetts after bachelor’s degree in
engineering, from Punjab Engineering College.
• In 1993, Sanghi became president and CEO of
Microchip after seeking advice from venture
capital firms on starting his own company.

he has transformed Microchip into a billion-dollar company specializing in Microcontroller and analog semiconductors used in devices ranging from remote controls to cars. .Since then. and he’s been known to frequent science fairs and question kids about their projects. He also has been involved in science and technology education programs.

These 8-bit micro controllers have become very important now -a -days in industrial automation and embedded applications etc…. . • The term PIC stands for “Peripheral Interface Controller” ..They have coined this name to identify their single chip micro-controllers. USA . Brief Introduction….It is the brain child of Microchip Technology.

availability of low cost or free development tools.• PICs are popular with both industrial developers and hobbyists alike due to their low cost. large user base. and serial programming (and re-programming with flash memory) capability. . extensive collection of application notes. wide availability.

They have limited program memory and are meant for applications requiring simple interface functions and small program & data memories. the micro-controller had a simple processor executing 12-bit wide instructions with basic I/O functions. These devices are known as low-end architectures.• Microchip PIC microcontrollers are available in various types. When PIC microcontroller MCU was first available from General Instruments in early 1980's. .

Some of the low-end device numbers are • 12C5XX • 16C5X • 16C505 .

Some of the mid-range devices are • 16C6X • 16C7X • 16F87X . more number of registers and more data/program memory. Mid range PIC architectures • built by upgrading low-end architectures with more number of peripherals.

• C = EPROM • F = Flash • RC = Mask ROM . Program memory type is indicated by an alphabet.

.40 pin DIP . These are available in 28 pin DIP.44 pin surface mount package…etc. The 7x family has an enhancement of Analog to Digital converter capability.• One of the mid -range versions of PIC Cs is PIC16C6x/7x. . These Cs are available with a range of capabilities packaged in both dual in-line (DIP) packages and surface-mount packages.

• In this 6x/7x family of Micro controllers . The presence of A indicates the brown-out reset feature.0 V. some of PIC do not contain this A. which causes a reset of the PIC when the Power Supply voltage drops below 4. . PIC 16C62A/PIC 16C74A are found with a suffix A.

• Instruction set Simplicity : The instruction set is so simple that it consists of just 35 instructions .2 s or five instructions per microsecond. Salient features • Speed : When operated at its maximum clock rate a PIC executes most of its instructions in 0.

A watch dog timer resets the PIC if the chip malfunctions or deviates from its normal operation at any time.• Integration of operational features: Power-on-reset and brown-out protection ensure that the chip operates only when the supply voltage is within specifications. . • Programmable timer options: Three timers can characterize inputs. control outputs and provide internal timing for the program execution.

• Powerful output pin control: A single instruction can select and drive a single output pin high or low in its 0. • I/O port expansion: With the help of built in serial peripheral interface the number of I/O ports can be expanded. . The PIN can drive a load of up to 25A. EPROM/DIP/ROM options are provided.2 s instruction execution time.

With the help of built in Serial Peripheral Interface(SPI) the number of I/O ports can be expanded. . • Interrupt control: Up to 12 independent interrupt sources can control when the CPU will deal with each sources.• I/O port expansion: This is the most important aspect in the PIC controllers. EPROM/DIP/ROM options are provided.

Timer 1. fully-static. PIC 16C6X/7X CONTROLLERS PERIPHERAL FEATURES • The PIC16CXX/17CXX is a family of low-cost. pre-scaler and post-scaler . CMOS. 8-bit microcontrollers. • There are Three Timers : Namely Timer 0. high-performance. Timer 2 • Timer 0: 8-bit timer/counter with 8-bit prescaler • Timer 1: 16-bit timer/counter with prescaler can be incremented during sleep via external crystal/clock • Timer 2: 8-bit timer/counter with 8-bit period register.

max resolution is 12.5 ns. Compare is 16-bit. max resolution is 200ns. PWM max resolution is 10-bit • Synchronous Serial Port (SSP) with SPITM and I2C • Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) . Contd… • Capture/Compare/PWM (CCP) module(s) • Capture is 16-bit.

• Parallel Slave Port (PSP) 8-bits wide. WR and CS controls • Brown-out detection circuitry for Brown-out Reset (BOR) • PIC16CXX microcontroller family has enhanced core features. . with external RD. and multiple internal and external interrupt sources. eight-level deep stack.

program and data are accessed from separate memories using separate buses. . the PIC 16CXX uses a Harvard architecture. in which. To begin with. ARCHITECTURE • The high performance of the PIC16CXX family can be attributed to a number of architectural features commonly found in RISC microprocessors. This improves bandwidth over traditional Von Neumann architecture where program and data may be fetched from the same memory using the same bus.


• Instructions are fetched from program memory using buses that are distinct from the buses used for accessing variables in data memory.• As the PIC 16c6x/7x family of micro-controllers uses Harvard Architecture it enables the devices exceptionally fast execution speed for a given clock rate. . Every instruction is coded as a single 14-bit word and fetched over a 14-bit wide bus. I/O ports etc. In the Harvard Architecture separate buses are used for Data and Instruction as shown in the diagram.

A 14-bit wide program memory access bus fetches a 14-bit instruction in a single cycle . Instruction op-codes are 14-bits wide making it possible to have all single word instructions. …. Contd • Separating program and data buses further allows instructions to be sized differently than 8-bit wide data words.


• The PIC 16C61 addresses 1K x 14 of
program memory.
• The PIC16C62/62A/R62/64 addresses 2K
x 14 of program memory, and
• the PIC16C63/R63/65/65/65A/R65
devices address 4K x 14 of program
• The PIC 16C66/67 address 8K x 14
program memory. All program memory is

• The PIC16CXX can directly or indirectly address
its register files or data memory. All special
function registers including the program counter
are mapped in the data memory. The PIC16CXX
has an orthogonal (symmetrical) instruction set
that makes it possible to carry out any operation
on any register using any addressing mode. This
symmetrical nature and lack of “special optimal
situations” makes programming with the
PIC16CXX simple yet efficient, thus significantly
reducing the learning curve.

Block Diagram-16C6X

CPU REGISTERS The CPU registers are • Working Register (W) • Status – Register • FSR – File Select Register • INDF • PCLATH • Program Counter • PCL • Eight Level Stack .

General Block Diagram .

the RESET status and the bank select bits for the data memory. It is a 8-bit regarding. • Status Register: It contains the arithmetic status of the ALU. Contd… • Working Register: Working Register is used by many instructions as the source of an operand. It also serves as the destination for the result of instruction execution and it is similar to accumulator in other cs and ps. .

out bit) RPO: Register bank Select The bits 7 and 6 of Status Register are unused by 16c6x/7x.C: Carry/borrow bit DC: Digit carry/borrow bit Z: Zero bit NOT_PD: Reset Status bit (Power-down mode bit) NOT_TO: Reset Status bit (tme. .

. • The DC or Digit carry bit indicates that a carry from the lower 4 bits occurred during an 8-bit addition. Contd… The ‘C’ bit is set when two 8-bit operands are added together and a 9-bit result occurs. This 9-bit is placed in the carry bit.

• Example: 0011 1000 0011 1000 0111 0000 Here DC=1 as a result of the carry from the bit 3 to the bit 4 position. .

Upon reset the CPU can check these two reset status bits to determine which kind of event resettled it and then respond accordingly. It can be reset by any of three kinds. The micro controller can put itself to sleep mode to save power during intervals when it has nothing to do. . • The reset status bits NOT_TO and NOT_PD are used in conjunction with PIC’s sleep mode.• The Z or zero bits is affected by the execution of arithmetic or logic instructions.

. When RPO=0. • Example: bcf STATUS.• The Register bank select bit RPO is used to select either bank . RPO Select bank 0 • bsf STATUS. select Bank 0. RPO Select bank 1. select Bank 1. RPO=1.

Addressing this INDF will cause indirect addressing. In the indirect addressing mode the 8-bit register file address is first written into FSR. Any instruction using the INDF register actually access the register pointed to by the FSR. • INDF – (Indirect File): It is not a physical register . Contd… • FSR – (File Select Register): It is the pointer used for indirect addressing. It is a special purpose register that serves as an address pointer to any address through out the entire register file. .

Contd… • PCL: PCL is actually the lower 8-bits of the 13-bit program counter. It can be read like any other register. • PCLATH (Program Counter Latch): The upper 3-bits of PCLATH remains zero and serves no purpose. . it is only when PC2 is written to that PCLATH is automatically written into the PC at the same time.

• Program memory • Data memory • Stack . Memory organisation : It has three memory blocks.

Program Memory • The 6x/7x family controllers have either 2k or 4k address of program memory. • A program memory of 4k address needs a 12-bit program counter. Normally a program memory of 2k addresses needs only a 11-bit program counter to access any address (211=2048=2k). But this PIC family uses 13-bit program counter allowing the controllers to an 8k-program memory without changing the CPU structure. .


.• Two addresses in the program memory address space are treated in a special way by the CPU. The first address H’ 000’ being a go to mainline instruction the second special address. H’ 004’ being a ‘go to in service’ instruction can be assigned to this address to make the CPU to jump to the beginning of the Interrupt Service routine located elsewhere in the memory space.


if any tables are created they are assigned to addresses in the range H’005 – H’0FF’. The main line program begins after the tables. .• When we deal with tables. For most of the applications this space is sufficient.

• General purpose register file ( RAM). Data memory (Register Files): Data Memory is also known as Register File. . Register File consists of two components. • Special purpose register file (similar to SFR in 8051).

• The special purpose register file consists of input/output ports and control registers. Therefore the register bank select (RP0) bit in the STATUS register is used to select one of the register bank . However. the instructions that use direct addressing modes in PIC to address these register files use 7 bits of instruction only. Addressing from 00H to FFH requires 8 bits of address.

Data Memory map .

execution starts from address 0 of the program memory. . The reset action also initializes various SFR registers inside the Microcontroller. This is where the first executable user program resides. Normally when a PIC microcontroller is reset. PIC Reset actions • Reset is used to put the microcontroller into a known state.

is generated by a flip-flop. and can be used to restart the CPU in case of program failure. S (Set) and R (Reset). . This has two inputs. • The actual reset to the CPU or the Chip_Reset. Contd… • Reset mechanisms ensure that the CPU starts running when the appropriate operating conditions have been met.

Contd…. • The S input to the flip-flop goes high. which is caused by the S line going high. if any of the following goes high: . via a three- input OR gate.. • The CPU enters Reset mode when Chip_Reset goes low. caused by the R line going high. It stays there until the flip-flop is cleared.

Contd….. Only 74 series have this feature . • The Reset action normally occurs in various situations like • Power On Reset • Master Clear( ) Reset • Watchdog Timer Reset • Brown-out Reset (This feature is not available in PIC16C61/62/64/65 series.

For Ex:Starting address for PIC16C71 is 000H.whereas for PIC16C57 it is 7FFH.This starting address is different for different members.. . Contd…. • So. • The reset action will set the program counterto the starting address of the program.The first instruction to be executed will appear at the reset vector.

but RAM locations are not initialized.the conclusion is Reset and Power-on are different in PIC controllers. • So.A reset cycle will initialize the RAM locations.most of the hardware registers are initialized . is when powered .• An important point to be remembered. .

If Vdd is hit with a transient noise spike .0Volts for longer than 100 micro seconds the Brown-out reset circuit detects that and reset the .. Contd…. • The Brown-out reset occurs when the supply voltage falls below 4 volts.causing Vdd to drop below 4.The Brown-out reset also includes another feature .The device remains in the Brown-out reset state till the supply voltage is restored.

• There is a provision of power-up timer of about 72mS. Contd…..whereas in most of the other microcontrollers many erroneous executions takes place during this time. • chip.The PIC brown-out reset will also help if the power-on reset conditions are not not met.Once this is enabled the Brown-out reset occurs once again incase of non-restoration of supply within 72 mS .

When using a crystal or resonator. canned oscillator modules. other components such as capacitors may be needed. Internal RC) • These modes support crystals. PIC Oscillator Connections • There are 4 common oscillator modes that are available on most PIC micro devices. some resonators or the use of an external resistor and capacitor as a clock source. Crystal. XT. • HS. (High speed. LP and RC. . Low- power clocking.

The important thing to remember about HS mode is that it provides the highest drive level available.and resonators with a frequency of 3 to 4 MHz or more. The gain on this signal controls whether an oscillation will occur and how strong it will be. Contd…. Care must be taken not to underdrive or overdrive the crystal or resonator.. • The HS mode stands for “High Speed” mode. Crystals and Resonators must be DRIVEN by a signal to work. It is designed to be used with crystals. .

Remember. • The XT mode stands for “Crystal” mode and will produce a medium drive level. • XT mode has moderate power consumption since its drive level is lower than that of HS mode. It is designed to be used with crystals and resonators of 1 to about 4 MHz. and because a lower clock speed is produced. as a rule: the faster the clock used. Contd…. the more current the application will require ..

LP mode is engineered for 32.. and as a result. • LP mode is ideal for timing sensitive applications since these same crystals are used as a time base in wrist-watches. This mode is useful for circuits that require the lowest power possible. the lowest power consumption of all the modes. . and it can function at any frequency below 200kHz. LP mode will produce the slowest clock rate.768kHz crystal operation. LP mode is most commonly used for 32. Contd…. • The LP mode stands for "Low Power” mode.768kHz operation.

these components are automatically driven to produce a frequency which will run the PICmicro MCU. • The RC mode stands for “External RC” mode. • RC mode uses a resistor-capacitor network connected to the OSC1 pin. When the device is configured for external RC mode.. • It is important to note that this is an _EXTERNAL_ RC mode. Contd…. . ( some PICmicro devices have an _INTERNAL_ RC mode).

Contd…. • RC mode is designed for very low-cost applications. The power consumed will vary due to the wide range of frequencies that can be created using this mode ..

. In some applications this won’t matter. For this reason.. Contd…. • It is extremely important to note that RC mode will produce an inaccurate clock source. RC mode is not recommended for timing sensitive applications or for RS-232 communication. but applications that are timing sensitive should not be used with this mode.

• The IntRC mode stands for “Internal RC” mode and functions much like the standard External RC mode. Microcontrollers with this feature have an on- chip RC oscillator. Contd…. Current designs run at approximately 4 MHz.. in IntRC mode the resistor and capacitor are already provided. • Unlike External RC mode. .

This feature makes the PIC12CXXX and other 8-pin PICmicro devices very popular.. because devices in this mode can often use the OSC1 and OSC2 lines for general purpose I/O. It is also useful. • IntRC mode is the least expensive oscillator available since no external components are needed. . Contd….

. • Similar to RC mode. and is low cost. it is not recommended for timing sensitive applications or for RS-232 use. One resistor controls the frequency produced. but no capacitor is needed.However. • ER mode is very similar to External RC mode. Contd…. • The ER mode stands for “External Resistor” mode. due to the nature of RC oscillators.. ER mode has moderate power consumption.


although indirect addressing is available via 2 additional registers • Register-bank switching is required to access the entire RAM of many devices . Limitations The PIC architectures have several limitations: • Only a single accumulator • A small instruction set • Operations and registers are not orthogonal. while others can only use the accumulator • Memory must be directly referenced in arithmetic and logic operations. some instructions can address RAM and/or immediate constants.

THANQ !! Wish you good luck .