My seminar new 28

39
Microchip ® PIC Microcontrollers Workshop by Midhu S.V. Unnithan

Transcript of My seminar new 28

Page 1: My seminar new 28

Microchip®®

PIC Microcontrollers

Workshop by

Midhu S.V. Unnithan

Page 2: My seminar new 28

Embedded Systems

What is Embedded System?

Embedded System is a combination of

software and hardware designed to perform a

specific task.

E.g. Washing Machine

Traffic Signal

Microwave Oven etc…

Page 3: My seminar new 28

Application Areas Of Embedded System

• Electronics Applications and Consumer Devices.

• Industrial Automation and Process Control.

• Access Control Systems.

• Security Systems.

• Robotics.

• Communications Applications.

• Automotive and Avionics Systems.

• Military and Aerospace Applications.

• Bio Medical Applications etc….

Page 4: My seminar new 28

Processing Parts Of Embedded System

1: Microprocessor (μp)

• Microprocessor is the Central Processing Unit.

• Microprocessor is, just simply, the processor .

• To make it to work it will need lots of external parts called peripherals. I.e. Microprocessor don’t have inbuilt peripherals.

• Micro processor needs many external circuits to make it work. So Microprocessor based system is called System On Board (SOB )

Page 5: My seminar new 28

Processing Parts Of Embedded System cont…

2: Microcontroller (μc )

• Microcontroller is the processing part in which all the essential peripherals are integrated in a single chip

• Microcontroller = Microprocessor + Peripherals

• It can process as well as control.

• It includes all the necessary parts in one IC. So microcontroller based system is called System On Chip (SOC)

Page 6: My seminar new 28

Microcontroller Manufactures

Page 7: My seminar new 28

Microchip’s PIC

• The name PIC referred to

"Peripheral Interface Controller"

• PIC is a family of Harvard Architecture microcontrollers made by Microchip Technology.

Microchip Technology is an American manufacturer of microcontroller, memory and analog semiconductors. The company was founded in 1987.

For more details log on to www.microchip.com

• PICs are popular with developers and hobbyists alike.

Page 8: My seminar new 28

Why PIC

• All the Peripherals are Integrated in a Single Chip

• Wide Range Available

• Cost Effective

• Easily Available

• High Speed

• High Performance RISC CPU

• Instruction Set Simplicity

• Wide Operating Voltage Range: 2.5 – 6 V

• Programmable Code Protection Mode

• Power Saving Sleep Mode

Page 9: My seminar new 28

Device Structure - PIC

• Core

The essential part of the system.

• Peripherals

Peripherals are the features that add a differentiation from

microprocessors. This is the interfacing units to external world.

• Special features

Major purpose of special features are

► Decrease system cost.

► Increase system reliability.

► Increase design flexibility.

Page 10: My seminar new 28

The PIC Family

• Based on Instruction Word Length PIC can be classified into three.

Instruction Word Length = OPCODE+OPERAND

• Base Line (12 bit with 33 Instructions)

• Mid Range (14 bit with 35 Instructions)

• High End (16 bit with 58 / 77 Instructions)

Page 11: My seminar new 28

Architectures …

1:Von Neumann Architecture

CPUCPU

Program Memory&

Data Memory

• Used in: 80X86, 8051 etc…

• Only one bus between CPU and memory.

• Data memory and Program memory share the same bus and the same memory, and so must have the same bit width.

• Time of execution high.

8

Page 12: My seminar new 28

Architectures …

2:Harvard Architecture

PICs use the Harvard Architecture

CPU121416

Data

Memory 8

Program

Memory

Used mostly in RISC CPUs.

Separate program bus and data bus: can be different widths.

Instructions can execute in a single cycle.

Time of execution is low.

Page 13: My seminar new 28

Name the PIC

• Microchips Microcontroller name always Starts with PIC

• Then a Number which denotes the Type/Range of that PIC

• 12 : Base Line (12 bit Instruction Word)• 16 : Mid Range (14 bit Instruction Word)• 17/18 : High End (16 bit Instruction Word)

• Next is an Alphabet which denotes How We Can Program the PIC

• CR : PROM (OTP)• C : PROM / EPROM• F : FLASH

• Last is another Number varies from PIC to PIC which denotes the internal memory, pin numbers, peripherals etc …

• 73 : 28 pin IC, 8 bit ADC, 4K PM etc…• 873 : 28 pin IC, 10 bit ADC, 4K PM etc…• 877 : 40pin IC, 10 bit ADC , 8K PM etc…• 877 A : 40pin IC, 10 bit ADC , 8K PM, New Batch IC etc…

Page 14: My seminar new 28

Name Yourself …….You can

• PIC16F73 :

• PIC16F873A :

• PIC16F877 :

• PIC16F877A :

Page 15: My seminar new 28

Instruction Set - PIC

• Only 35 instructions.

• RISC instruction architecture.

• In PIC, Accumulator is named as Working Register (w). This is the base register of all operations.

• All operations are possible only through ‘w’

• Register to register transfer is not possible.

• The instruction set is highly orthogonal and is grouped into three basic categories:

• Byte oriented instructions (18 nos).

• Bit oriented instructions (4 nos).

• Literal and control instructions (13 nos).

Page 16: My seminar new 28

Instruction Set - PIC1. Byte oriented instructions: (18 nos)

• CLRW - Clear working register.

• CLRF - Clear file register

• MOVFW - Move the contents of file register to working register.

• MOVWF - Move the contents of working register to file register.

• ADDWF - Add the contents of file register to working register.

• SUBWF - Subtract working register from the file register.

• ANDWF - Bit wise multiplication of working register with the file register.

• IORWF - Bit wise adding of working register with the file register.

• XORWF - Exclusive OR the contents of working register with the file reg:

• RLF - Rotate left with carry.

• RRF - Rotate right with carry.

• DECF - Decrement the file registers contents.

• DECFSZ - Decrement the contents of file register and skip the next instruction if zero.

• INCF - Increment the file registers contents.

• INCFSZ - Increment the contents of file register and skip the next instruction if zero.

• COMF - 1’s complement.

• SWAPF - Interchange the nibbles.

• NOP - No operation.

Page 17: My seminar new 28

Instruction Set - PIC

2. Bit Oriented instructions: (4 nos)

• BCF - Bit clear flag.

• BSF - Bit set flag.

• BTFSC - Bit test file register and skip if clear.

• BTFSS - Bit test file register and skip if set.

Page 18: My seminar new 28

Instruction Set - PIC

3. Literal and control instructions: (13 nos)

• MOVLW - Direct loading of working register.

• ADDLW - Direct adding of working register with a constant value.

• SUBLW - Direct subtraction of working register with a constant value.

• ANDLW - Bit wise multiplication of working register with a constant value.

• IORLW - Bit wise addition of working register with a constant value.

• XORLW - Exclusive OR of working register with a constant value.

• CALL XX - Call subroutine XX.

• RETURN - Back to main program from the subroutine.

• GOTO XX - Go to xx.

• RETFIE - Return from interrupts.

• RETLW - Return with literal value.

• CLRWDT - Clear watchdog timer.

• SLEEP - Low power consumption mode.

Page 19: My seminar new 28

Program Format

LIST P=PIC16F73 ;Listing the microcontroller

#INCLUDE“P16F73.INC” ;INC file

CBLOCK 0X20 ;GPR address starts from 0X20• • ;GPR Initialization•

ENDC

ORG 0 ;Reset Vector• • program• • •

END ;Program End

Page 20: My seminar new 28

Our First Program … • Add the contents of two registers (R1 & R2) and store the result in

R3

LIST P=PIC16F73

#INCLUDE“P16F73.INC”

CBLOCK 0X20

R1

R2

R3

END C

ORG 0

MOVLW 0X02

MOVWF R1

MOVLW 0X03

MOVWF R2

ADDWF R1,0

MOVWF R3

END

Page 21: My seminar new 28

Do it yourself …

• Subtract the contents of M1 from M2 and store the result in Y1

• Multiply the contents of X1 with X2 and store the result in X3.

Page 22: My seminar new 28

Its time to relax ….. Have a break…

Page 23: My seminar new 28

MPLAB IDE …An Introduction

• MPLAB IDE is a software program that runs on a PC, to develop applications for Microchip microcontrollers. It is called an Integrated Development Environment, or IDE, because it provides a single integrated “environment” to develop code for PIC microcontrollers.

• You can download this software free of cost from Microchip’s website. (www.microchip.com)

Page 24: My seminar new 28

Most Commonly Used SFR s …

• STATUS

• OPTION_REG

• PORTA,B,C…. & TRIS A,B,C…

• ADCON0,ADCON1,ADRES

• TXSTA,RCSTA,TXREG,RCREG,SPBRG

• INTCON etc………..

Page 25: My seminar new 28

That’s all with the software….

Lets have some Circuit Thoughts

Page 26: My seminar new 28

Pinout Diagram – 28 pin

Page 27: My seminar new 28

Pinout Diagram – 40 pin

Page 28: My seminar new 28

Basic Circuit Requirements of PIC

1: Power Supply

VDD = 5V

VSS = GND

Page 29: My seminar new 28

Basic Circuit Requirements of PIC

2: Connect Oscillator (XTAL 4 or 20 MHz) to CLKI and CLKO pins

Also connect two 22/33 pf capacitors with the crystal as shown below for crystal stabilization.

Page 30: My seminar new 28

Basic Circuit Requirements of PIC

3: Pull up MCLR pin with a 10k resistance to avoid master reset.

Page 31: My seminar new 28

Here is your PIC basic circuit

Page 32: My seminar new 28

SOFTWARE is ready….

HARDWARE is ready….

Its Time To Know How To Fuse The Program in PIC

Page 33: My seminar new 28

Programmers…

• Parallel Programmers

• Serial Programmers

• USB Programmers

Page 34: My seminar new 28

How To Program The PIC

Page 35: My seminar new 28

Brief Project Lifecycle

• Requirement Study

• Initial Planning

• Prototype development May again go to Requirement study

• Final Project Planning Deadlines, Team/Recourses, Methods, Budget

• Development Hardware and Software

• Testing and Debugging May again go to Development

• Documentation

• Project Delivery

Page 36: My seminar new 28
Page 37: My seminar new 28

Feedbacks and Suggestions Please…..

Page 38: My seminar new 28

We can't solve problems by using the same kind of thinking we used when we created them. So Think Different (Albert Einstein)

I wish you all a very successful future….Take care

[email protected]

Page 39: My seminar new 28