SlideShare a Scribd company logo
1 of 48
Download to read offline
PIC Microcontroller
Dr. Ritula Thakur
Contents
❖ History and Features
❖ Architecture
❖ Pipelining
❖ Pin Diagram of PIC18F458
❖ I/O port pins and their functions
❖ PIC18 Configuration Registers
History and Development
❖ PIC stands for Peripheral Interface Controller.
❖ The PIC microcontroller was developed by General Instruments in 1975.
PIC was developed when Microelectronics Division of General Instruments
was testing its 16- bit CPU CP1600. Although the CP1600 was a good CPU
but it had low I/O performance.The PIC controller was used to offload the
I/O tasks from CPU to improve the overall performance of the system.
❖ In 1985, General Instruments converted their Microelectronics Division to
MicrochipTechnology.The General Instruments used the acronyms
Programmable Interface Controller and Programmable Intelligent
Computer for the initial PICs (PIC1640 and PIC1650).
❖ In 1993, MicrochipTechnology launched the 8-bit PIC16C84 with EEPROM
which could be programmed using serial programming method.The
improved version of PIC16C84 with flash memory (PIC18F84 and
PIC18F84A) hit the market in 1998.
History and Development
❖ Since 1998, MicrochipTechnology continuously developed new
high performance microcontrollers with new complex architecture
and enhanced in-built peripherals
❖ PIC microcontroller is based on Harvard architecture.
❖ At present PIC microcontrollers are widely used for industrial
purpose due to its high performance ability at low power
consumption.
❖ It is also very famous among hobbyists due to moderate cost and
easy availability of its supporting software and hardware tools like
compilers, simulators, debuggers etc.
Features of PIC Microcontrollers
The 8-bit PIC microcontroller is divided into following four
categories on the basis of internal architecture:
1. Baseline PIC
2. Mid-Range PIC
3. Enhanced Mid-Range PIC
4. PIC18
Features of PIC Microcontrollers
1. Baseline PIC
❖ Base Line PICs are the least complex PIC microcontrollers.
❖ These microcontrollers work on 12-bit instruction
architecture which means that the word size of instruction
sets are of 12 bits for these controllers.
❖ These are smallest and cheapest PICs, available with 6 to 40
pin packaging.
❖ The small size and low cost of Base Line PIC replaced the
traditional ICs like 555, logic gates etc. in industries.
Features of PIC Microcontrollers
2. Mid-Range PIC
❖ Mid-Range PICs are based on 14-bit instruction architecture
and are able to work up to 20 MHz speed.
❖ These controllers are available with 8 to 64 pin packaging.
These microcontrollers are available with different
peripherals like ADC, PWM, Op-Amps and different
communication protocols like USART, SPI, I2C (TWI), etc.
which make them widely usable microcontrollers not only
for industry but for hobbyists as well.
Features of PIC Microcontrollers
3. Enhanced Mid-Range PIC
❖ These controllers are enhanced version of Mid-Range core.
❖ This range of controllers provides
➢ additional performance,
➢ greater flash memory
➢ high speed
➢ very low power consumption.
❖ This range of PIC also includes multiple peripherals and
supports protocols like USART, SPI, I2C and so on.
Features of PIC Microcontrollers
4. PIC18
❖ PIC18 range is based on 16-bit instruction architecture
incorporating advanced RISC architecture which makes it
highest performer among the all 8-bit PIC families.
❖ The PIC18 range is integrated with new age communication
protocols like USB, CAN, LIN, Ethernet (TCP/IP protocol) to
communicate with local and/or internet based networks.
❖ This range also supports the connectivity of Human Interface
Devices like touch panels etc.
❖ Besides 8-bit microcontrollers, Microchip also
manufactures 16-bit and 32-bit
microcontrollers.
❖ Recently Microchip developed XLP (Extreme
Low Power) series microcontrollers which are
based on NanoWatt technology.
❖ These controllers draw current in order of
nanoamperes(nA).
Memory variations:
The PIC microcontrollers are available with different memory options
which are mask ROM, EPROM and flash memory.They are denoted with
different symbols as given in the following table:
Architecture:
❖ Advanced RISC Architecture
➢ RISC stands for Reduced Instruction Set Computing.
● the instruction set of hardware gets reduced
● increases the execution rate (speed) of system.
❖ Harvard Architecture
➢ There are two separate memories for program and data.
➢ These two memories are accessed through different buses for
data communication between memories and CPU core.
➢ This architecture improves the speed of system over Von
Neumann architecture in which program and data are fetched
from the same memory using the same bus.
PIC18 series controllers are based on 16-bit
instruction set.
PIC18 Harvard Architecture
● The above process occurs in a single machine cycle.
● In PIC microcontroller, a single machine cycle consists of 4 oscillation
periods.
● Thus an instruction needs 4 clock periods to be executed.
● This makes it faster than other 8051 microcontrollers.
Pipelining:
❖ Early processors and controllers could fetch or execute a single
instruction in a unit of time.
❖ The PIC microcontrollers are able to fetch and execute the instructions in
the same unit of time thus increasing their instruction throughput.
❖ This technique is known as instruction pipelining where the processing of
instructions is split into a number of independent steps.
PIC18F458
Pin Diagram of PIC18F458
I/O Port Pins : Functions
❖ Port pins vary, depending upon CHIP
❖ e.g. 18pin PIC18 has Ports A and B only
Not all ports have 8 pins
❖ Port A has 7 pins
❖ Ports B,C and D each have 8 pins
❖ Port E has only 3 pins
I/O Functions of PIC18
Each Port has 3 SFRs
❖ PORTx,TRISx, LATx
❖ TRIS stands forTRIState
❖ LAT stands for Latch
I/O Functions of PIC18
❖ Input / output to be programmed
❖ Each PORT has some other function, ADC,Timers etc
❖ Each PORT has three SFRs (PORTx,TRISx, LATx)
❖ TRIS: TRIState; LAT: LATch
❖ Upon “RESET”,TRIS is ‘1’ i.e. all input port
I/O Port Pins : Functions
TRIS register: Role in outputting DATA
❖ Each PORT can be input/output
❖ TRIS used to define port input/output
❖ output data:TRIS is ‘0’; input data:TRIS is ‘1’
❖ WithoutTRIS, no DATA is processed at PORT
Write a C18 program to send values 00-FF to PORT B
#include<PIC18F458.h>
Void main(void)
{
Unsigned char z;
TRISB =0; // make Port B an output
While (1)
{
For(z=0;z<=255;z++)
PORTB = z;
}
}
Write a C18 program to toggle all the bits
of Port B continuously
#include<PIC18F458.h>
Void main (void)
{
TRISB =0; // make Port B as output
While(1)
{
PORTB = 0x55;
PORTB = 0xAA;
}
}
Write a C18 program to toggle all the bits
of Port B continuously with some delay
#include<PIC18F458.h>
Void main (void)
{
unsigned int x;
TRISB =0;
while(1)
{_
PORTB = 0x55;
for(x=0;x<50000;x++);
PORTB = 0xAA;
for(x=0;x<50000;x++);
}
}
Write a C18 program to toggle all the bits
of Port B continuously with a 250 ms delay.
#include<PIC18F458.h>
Void MSDelay (unsigned int);
Void main (void)
{
TRISB =0;
While(1)
{
PORTB = 0x55;
MSDELAY (250);
PORTB = 0xAA;
MSDELAY (250);
}
}
Void MSDelay (unsigned int itime)
{
Unsigned int i,j;
For(i=0;i<itime;i++)
For (j=0;j<165;j++);
}
Write a C18 program to toggle all the bits
of Port B 50000 times.
#include<PIC18F458.h>
Void MSDelay (unsigned int);
Void main (void)
{
unsigned int z;
TRISB =0;
for(z=0;z<50000;z++)
{
PORTB = 0x55;
PORTB = 0xAA;
}
}
Write a C18 program to get a byte of data from
Port B, wait ½ second, and send it to Port C.
#include<PIC18F458.h>
Void MSDelay (unsigned int);
Void main (void)
{
Unsigned char mybyte;
TRISB =0xFF; //make PORT B an input port
TRISC = 0; // make PORT C an output port
While(1)
{
mybyte= PORTB;
MSDELAY (500);
PORTC = mybyte;
MSDELAY (500);
}
}
Void MSDelay (unsigned int itime)
{
Unsigned int i,j;
For(i=0;i<itime;i++)
For (j=0;j<165;j++);
}
Bit- addressable I/O programming
Bit- addressable I/O programming
PORTxbits.Rxy,
x is the PORT, y is the bit of that port
eg PORTAbits.RA7 denotes PORTA.7
#define name PORTxbits.Rxy
For making input or output bits
TRISAbits.TRISA7 indicates the D7 ofTRISA
Write a C18 program to toggle only
bit RB4 continuously without
disturbing the rest of the bits of
PORT B
#include<PIC18F458.h>
#define mybit PORTBbits.RB4 //declare single bit
Void main(void)
{
TRISBbits.TRISB4 =0; // make Port pin RB4 an output
While (1)
{
Mybit =0; //turn off RB4
Mybit= 1; // turn off RB4
}
}
A door sensor is connected to the RB1 pin and a buzzer is
connected to RC7. Write a C18 program to monitor the door
sensor, when it opens, sound the buzzer by sending a
square wave of a few hundred Hz frequency to it.
#include<PIC18F458.h>
Void MSDelay (unsigned int);
#define Dsensor = PORTBbits.RB1
#define buzzer = PORTCbits.RC7
Void main (void)
{
TRISBbits.TRISB1 =1; //make PORT B.1 an input bit
TRISCbits.TRISC7= 0; // make PORT C.7 an output bit
While(1)
{
while( Dsensor==1);
{
buzzer = 1;
MSDELAY (500);
buzzer = 0;
MSDELAY (500);
}
}
Void MSDelay (unsigned int itime)
{
Unsigned int i,j;
For(i=0;i<itime;i++)
For (j=0;j<165;j++);
}
Write a C18 program to toggle all bits of Port B
100000 times.
Hint- short long (0 to 16777215)
#include<PIC18F458.h>
Void main (void)
{
Unsigned short long z;
TRISB =0; // make Port B as output port
For (z=0;z<100000;z++)
{
PORT B = 0x55; // assign value 55 H to port B
PORT B= 0xAA; // assign value AA H to port B to
toggle it
}
}
Logic Operations in C
▪ Bitwise operators are special operator set
provided by 'C.'
▪ They are used in bit level programming.
▪ These operators are used to manipulate bits
of an integer expression.
▪ Logical, shift and complement are three
types of bitwise operators.
▪ Bitwise complement operator is used to
reverse the bits of an expression.
Write a C18 program to toggle all the bits of PORT b
And PORT C continuously with a 250 ms delay. Use the
EX-OR operator
#include<PIC18F458.h>
Void MSDelay (unsigned int);
Void main (void)
{
TRISB =0; // make Port B and output port 0 0 0
TRISC =0; // make Port C and output port 0 1 1
PORTB = 0x55; 1 0 1
PORTC = 0x55; 1 1 0
While(1)
{
PORTB = PORTB ^ 0xFF; // 01010101 ^ 11111111 = 10101010
MSDELAY (250);
PORTC = PORT C^0xFF; // 01010101 ^ 11111111 = 10101010
MSDELAY (250);
}
}
Void MSDelay (unsigned int itime)
{
Unsigned int i,j;
For(i=0;i<itime;i++)
For (j=0;j<165;j++);
}
Write a C18 program to get RB0 and send it to
RC7 after inverting it
#include <PIC18F458.h>
#define mybit1 PORTBbits.RB0
#define mybit2 PORTCbits.RC7
Void main (void)
{
TRISBbits.TRISB0 =1; // make RB0 an input bit
TRISCbits.TRISC7 =0; //make RC7 a output bit
While (1)
{
mybit2 = ~ mybit1;
}
}

Every timer needs a clock pulse
to tick

Clock source can be
◦ Internal- 1/4th of the frequency of the
crystal oscillator on OSC1 and OSC2 pins
(Fosc/4) is fed into timer. Therefore, it is
used for time delay generation and hence
called timer.
◦ External-pulses are fed through one of the
PIC18’s pins and is known as Counter.

Serializing data is a way of sending a byte of
data one bit at a time through a single pin of a
microcontroller.
DATA Serialization in C
Two ways to transfer a byte
of data Serially
▪ Using Serial Port
Limited control over sequence of data transfer
▪ Transfer data one bit a time
Control of sequence of data and spaces between
them
PIC18 Timer Programming in C
PIC 18 has two to five timers depending on the
family member- Timers 0, 1, 2, 3 and 4
▪ Can be either used as timers to generate a
time delay
▪ Or as counters to count events happening
outside the microcontroller
Basics Registers of the
timer
▪Timers are 16-bit wide
◦Can be accessed as two
separate reg.
◦Low Byte(TMRxL) & High Byte
TMRxH)
◦Each timer also has TCON (timer
Control) reg for setting modes of
operation.
PIC18F458_Ritula Thakur.pptx.pdf

More Related Content

Similar to PIC18F458_Ritula Thakur.pptx.pdf

Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdf
Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdfPic16f877a microcontroller based projects list _ PIC Microcontroller.pdf
Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdfIsmailkhan77481
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mappingOsaMa Hasan
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureJamia Hamdard
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28rajeshkvdn
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copymkazree
 
chapter2-part1-140329134839-phpapp02.pptx
chapter2-part1-140329134839-phpapp02.pptxchapter2-part1-140329134839-phpapp02.pptx
chapter2-part1-140329134839-phpapp02.pptxSangeetaTripathi8
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller pavihari
 
Presentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Presentation for EEE engineers on Microcontroller by Dilip Kumar RoyPresentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Presentation for EEE engineers on Microcontroller by Dilip Kumar RoyDilip Kumar Ckt
 
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSPIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSVISHNU KP
 

Similar to PIC18F458_Ritula Thakur.pptx.pdf (20)

Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdf
Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdfPic16f877a microcontroller based projects list _ PIC Microcontroller.pdf
Pic16f877a microcontroller based projects list _ PIC Microcontroller.pdf
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Picmico
PicmicoPicmico
Picmico
 
Atmega 16 drdo report
Atmega 16 drdo reportAtmega 16 drdo report
Atmega 16 drdo report
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
Atmega16
Atmega16Atmega16
Atmega16
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copy
 
embedded system and AVR
embedded system and AVRembedded system and AVR
embedded system and AVR
 
chapter2-part1-140329134839-phpapp02.pptx
chapter2-part1-140329134839-phpapp02.pptxchapter2-part1-140329134839-phpapp02.pptx
chapter2-part1-140329134839-phpapp02.pptx
 
Presentation
PresentationPresentation
Presentation
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
Presentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Presentation for EEE engineers on Microcontroller by Dilip Kumar RoyPresentation for EEE engineers on Microcontroller by Dilip Kumar Roy
Presentation for EEE engineers on Microcontroller by Dilip Kumar Roy
 
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERSPIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
 
Introduction to 8085 by Adi PPT.pdf
Introduction to 8085 by Adi PPT.pdfIntroduction to 8085 by Adi PPT.pdf
Introduction to 8085 by Adi PPT.pdf
 

More from AvinashJain66

Graphs and waveforms.ppt
Graphs and waveforms.pptGraphs and waveforms.ppt
Graphs and waveforms.pptAvinashJain66
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptxAvinashJain66
 
Loop Concept and Array.ppt
Loop Concept and Array.pptLoop Concept and Array.ppt
Loop Concept and Array.pptAvinashJain66
 
Looping concept.pptx
Looping concept.pptxLooping concept.pptx
Looping concept.pptxAvinashJain66
 
Virtual Instrumentation & LabVIEW-lini.ppt
Virtual Instrumentation & LabVIEW-lini.pptVirtual Instrumentation & LabVIEW-lini.ppt
Virtual Instrumentation & LabVIEW-lini.pptAvinashJain66
 
Lecture-6-PIC Programming in C-good.pdf
Lecture-6-PIC Programming in C-good.pdfLecture-6-PIC Programming in C-good.pdf
Lecture-6-PIC Programming in C-good.pdfAvinashJain66
 

More from AvinashJain66 (8)

FACTS.pdf
FACTS.pdfFACTS.pdf
FACTS.pdf
 
Graphs and waveforms.ppt
Graphs and waveforms.pptGraphs and waveforms.ppt
Graphs and waveforms.ppt
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
Loop Concept and Array.ppt
Loop Concept and Array.pptLoop Concept and Array.ppt
Loop Concept and Array.ppt
 
Looping concept.pptx
Looping concept.pptxLooping concept.pptx
Looping concept.pptx
 
Virtual Instrumentation & LabVIEW-lini.ppt
Virtual Instrumentation & LabVIEW-lini.pptVirtual Instrumentation & LabVIEW-lini.ppt
Virtual Instrumentation & LabVIEW-lini.ppt
 
Lecture-6-PIC Programming in C-good.pdf
Lecture-6-PIC Programming in C-good.pdfLecture-6-PIC Programming in C-good.pdf
Lecture-6-PIC Programming in C-good.pdf
 
Relay-ppt.pptx
Relay-ppt.pptxRelay-ppt.pptx
Relay-ppt.pptx
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 

PIC18F458_Ritula Thakur.pptx.pdf

  • 2. Contents ❖ History and Features ❖ Architecture ❖ Pipelining ❖ Pin Diagram of PIC18F458 ❖ I/O port pins and their functions ❖ PIC18 Configuration Registers
  • 3. History and Development ❖ PIC stands for Peripheral Interface Controller. ❖ The PIC microcontroller was developed by General Instruments in 1975. PIC was developed when Microelectronics Division of General Instruments was testing its 16- bit CPU CP1600. Although the CP1600 was a good CPU but it had low I/O performance.The PIC controller was used to offload the I/O tasks from CPU to improve the overall performance of the system. ❖ In 1985, General Instruments converted their Microelectronics Division to MicrochipTechnology.The General Instruments used the acronyms Programmable Interface Controller and Programmable Intelligent Computer for the initial PICs (PIC1640 and PIC1650). ❖ In 1993, MicrochipTechnology launched the 8-bit PIC16C84 with EEPROM which could be programmed using serial programming method.The improved version of PIC16C84 with flash memory (PIC18F84 and PIC18F84A) hit the market in 1998.
  • 4. History and Development ❖ Since 1998, MicrochipTechnology continuously developed new high performance microcontrollers with new complex architecture and enhanced in-built peripherals ❖ PIC microcontroller is based on Harvard architecture. ❖ At present PIC microcontrollers are widely used for industrial purpose due to its high performance ability at low power consumption. ❖ It is also very famous among hobbyists due to moderate cost and easy availability of its supporting software and hardware tools like compilers, simulators, debuggers etc.
  • 5. Features of PIC Microcontrollers The 8-bit PIC microcontroller is divided into following four categories on the basis of internal architecture: 1. Baseline PIC 2. Mid-Range PIC 3. Enhanced Mid-Range PIC 4. PIC18
  • 6. Features of PIC Microcontrollers 1. Baseline PIC ❖ Base Line PICs are the least complex PIC microcontrollers. ❖ These microcontrollers work on 12-bit instruction architecture which means that the word size of instruction sets are of 12 bits for these controllers. ❖ These are smallest and cheapest PICs, available with 6 to 40 pin packaging. ❖ The small size and low cost of Base Line PIC replaced the traditional ICs like 555, logic gates etc. in industries.
  • 7. Features of PIC Microcontrollers 2. Mid-Range PIC ❖ Mid-Range PICs are based on 14-bit instruction architecture and are able to work up to 20 MHz speed. ❖ These controllers are available with 8 to 64 pin packaging. These microcontrollers are available with different peripherals like ADC, PWM, Op-Amps and different communication protocols like USART, SPI, I2C (TWI), etc. which make them widely usable microcontrollers not only for industry but for hobbyists as well.
  • 8. Features of PIC Microcontrollers 3. Enhanced Mid-Range PIC ❖ These controllers are enhanced version of Mid-Range core. ❖ This range of controllers provides ➢ additional performance, ➢ greater flash memory ➢ high speed ➢ very low power consumption. ❖ This range of PIC also includes multiple peripherals and supports protocols like USART, SPI, I2C and so on.
  • 9. Features of PIC Microcontrollers 4. PIC18 ❖ PIC18 range is based on 16-bit instruction architecture incorporating advanced RISC architecture which makes it highest performer among the all 8-bit PIC families. ❖ The PIC18 range is integrated with new age communication protocols like USB, CAN, LIN, Ethernet (TCP/IP protocol) to communicate with local and/or internet based networks. ❖ This range also supports the connectivity of Human Interface Devices like touch panels etc.
  • 10.
  • 11. ❖ Besides 8-bit microcontrollers, Microchip also manufactures 16-bit and 32-bit microcontrollers. ❖ Recently Microchip developed XLP (Extreme Low Power) series microcontrollers which are based on NanoWatt technology. ❖ These controllers draw current in order of nanoamperes(nA).
  • 12. Memory variations: The PIC microcontrollers are available with different memory options which are mask ROM, EPROM and flash memory.They are denoted with different symbols as given in the following table:
  • 13. Architecture: ❖ Advanced RISC Architecture ➢ RISC stands for Reduced Instruction Set Computing. ● the instruction set of hardware gets reduced ● increases the execution rate (speed) of system. ❖ Harvard Architecture ➢ There are two separate memories for program and data. ➢ These two memories are accessed through different buses for data communication between memories and CPU core. ➢ This architecture improves the speed of system over Von Neumann architecture in which program and data are fetched from the same memory using the same bus.
  • 14. PIC18 series controllers are based on 16-bit instruction set.
  • 15. PIC18 Harvard Architecture ● The above process occurs in a single machine cycle. ● In PIC microcontroller, a single machine cycle consists of 4 oscillation periods. ● Thus an instruction needs 4 clock periods to be executed. ● This makes it faster than other 8051 microcontrollers.
  • 16. Pipelining: ❖ Early processors and controllers could fetch or execute a single instruction in a unit of time. ❖ The PIC microcontrollers are able to fetch and execute the instructions in the same unit of time thus increasing their instruction throughput. ❖ This technique is known as instruction pipelining where the processing of instructions is split into a number of independent steps.
  • 18. Pin Diagram of PIC18F458
  • 19. I/O Port Pins : Functions ❖ Port pins vary, depending upon CHIP ❖ e.g. 18pin PIC18 has Ports A and B only
  • 20. Not all ports have 8 pins ❖ Port A has 7 pins ❖ Ports B,C and D each have 8 pins ❖ Port E has only 3 pins I/O Functions of PIC18
  • 21. Each Port has 3 SFRs ❖ PORTx,TRISx, LATx ❖ TRIS stands forTRIState ❖ LAT stands for Latch I/O Functions of PIC18
  • 22. ❖ Input / output to be programmed ❖ Each PORT has some other function, ADC,Timers etc ❖ Each PORT has three SFRs (PORTx,TRISx, LATx) ❖ TRIS: TRIState; LAT: LATch ❖ Upon “RESET”,TRIS is ‘1’ i.e. all input port I/O Port Pins : Functions TRIS register: Role in outputting DATA ❖ Each PORT can be input/output ❖ TRIS used to define port input/output ❖ output data:TRIS is ‘0’; input data:TRIS is ‘1’ ❖ WithoutTRIS, no DATA is processed at PORT
  • 23.
  • 24. Write a C18 program to send values 00-FF to PORT B #include<PIC18F458.h> Void main(void) { Unsigned char z; TRISB =0; // make Port B an output While (1) { For(z=0;z<=255;z++) PORTB = z; } }
  • 25. Write a C18 program to toggle all the bits of Port B continuously #include<PIC18F458.h> Void main (void) { TRISB =0; // make Port B as output While(1) { PORTB = 0x55; PORTB = 0xAA; } }
  • 26. Write a C18 program to toggle all the bits of Port B continuously with some delay #include<PIC18F458.h> Void main (void) { unsigned int x; TRISB =0; while(1) {_ PORTB = 0x55; for(x=0;x<50000;x++); PORTB = 0xAA; for(x=0;x<50000;x++); } }
  • 27. Write a C18 program to toggle all the bits of Port B continuously with a 250 ms delay. #include<PIC18F458.h> Void MSDelay (unsigned int); Void main (void) { TRISB =0; While(1) { PORTB = 0x55; MSDELAY (250); PORTB = 0xAA; MSDELAY (250); } } Void MSDelay (unsigned int itime) { Unsigned int i,j; For(i=0;i<itime;i++) For (j=0;j<165;j++); }
  • 28. Write a C18 program to toggle all the bits of Port B 50000 times. #include<PIC18F458.h> Void MSDelay (unsigned int); Void main (void) { unsigned int z; TRISB =0; for(z=0;z<50000;z++) { PORTB = 0x55; PORTB = 0xAA; } }
  • 29. Write a C18 program to get a byte of data from Port B, wait ½ second, and send it to Port C. #include<PIC18F458.h> Void MSDelay (unsigned int); Void main (void) { Unsigned char mybyte; TRISB =0xFF; //make PORT B an input port TRISC = 0; // make PORT C an output port While(1) { mybyte= PORTB; MSDELAY (500); PORTC = mybyte; MSDELAY (500); } } Void MSDelay (unsigned int itime) { Unsigned int i,j; For(i=0;i<itime;i++) For (j=0;j<165;j++); }
  • 30. Bit- addressable I/O programming
  • 31. Bit- addressable I/O programming PORTxbits.Rxy, x is the PORT, y is the bit of that port eg PORTAbits.RA7 denotes PORTA.7 #define name PORTxbits.Rxy For making input or output bits TRISAbits.TRISA7 indicates the D7 ofTRISA
  • 32. Write a C18 program to toggle only bit RB4 continuously without disturbing the rest of the bits of PORT B
  • 33. #include<PIC18F458.h> #define mybit PORTBbits.RB4 //declare single bit Void main(void) { TRISBbits.TRISB4 =0; // make Port pin RB4 an output While (1) { Mybit =0; //turn off RB4 Mybit= 1; // turn off RB4 } }
  • 34. A door sensor is connected to the RB1 pin and a buzzer is connected to RC7. Write a C18 program to monitor the door sensor, when it opens, sound the buzzer by sending a square wave of a few hundred Hz frequency to it.
  • 35. #include<PIC18F458.h> Void MSDelay (unsigned int); #define Dsensor = PORTBbits.RB1 #define buzzer = PORTCbits.RC7 Void main (void) { TRISBbits.TRISB1 =1; //make PORT B.1 an input bit TRISCbits.TRISC7= 0; // make PORT C.7 an output bit While(1) { while( Dsensor==1); { buzzer = 1; MSDELAY (500); buzzer = 0; MSDELAY (500); } } Void MSDelay (unsigned int itime) { Unsigned int i,j; For(i=0;i<itime;i++) For (j=0;j<165;j++); }
  • 36. Write a C18 program to toggle all bits of Port B 100000 times. Hint- short long (0 to 16777215)
  • 37. #include<PIC18F458.h> Void main (void) { Unsigned short long z; TRISB =0; // make Port B as output port For (z=0;z<100000;z++) { PORT B = 0x55; // assign value 55 H to port B PORT B= 0xAA; // assign value AA H to port B to toggle it } }
  • 38. Logic Operations in C ▪ Bitwise operators are special operator set provided by 'C.' ▪ They are used in bit level programming. ▪ These operators are used to manipulate bits of an integer expression. ▪ Logical, shift and complement are three types of bitwise operators. ▪ Bitwise complement operator is used to reverse the bits of an expression.
  • 39.
  • 40. Write a C18 program to toggle all the bits of PORT b And PORT C continuously with a 250 ms delay. Use the EX-OR operator #include<PIC18F458.h> Void MSDelay (unsigned int); Void main (void) { TRISB =0; // make Port B and output port 0 0 0 TRISC =0; // make Port C and output port 0 1 1 PORTB = 0x55; 1 0 1 PORTC = 0x55; 1 1 0 While(1) { PORTB = PORTB ^ 0xFF; // 01010101 ^ 11111111 = 10101010 MSDELAY (250); PORTC = PORT C^0xFF; // 01010101 ^ 11111111 = 10101010 MSDELAY (250); } } Void MSDelay (unsigned int itime) { Unsigned int i,j; For(i=0;i<itime;i++) For (j=0;j<165;j++); }
  • 41. Write a C18 program to get RB0 and send it to RC7 after inverting it #include <PIC18F458.h> #define mybit1 PORTBbits.RB0 #define mybit2 PORTCbits.RC7 Void main (void) { TRISBbits.TRISB0 =1; // make RB0 an input bit TRISCbits.TRISC7 =0; //make RC7 a output bit While (1) { mybit2 = ~ mybit1; } }
  • 42.  Every timer needs a clock pulse to tick  Clock source can be ◦ Internal- 1/4th of the frequency of the crystal oscillator on OSC1 and OSC2 pins (Fosc/4) is fed into timer. Therefore, it is used for time delay generation and hence called timer. ◦ External-pulses are fed through one of the PIC18’s pins and is known as Counter. 
  • 43. Serializing data is a way of sending a byte of data one bit at a time through a single pin of a microcontroller. DATA Serialization in C
  • 44. Two ways to transfer a byte of data Serially ▪ Using Serial Port Limited control over sequence of data transfer ▪ Transfer data one bit a time Control of sequence of data and spaces between them
  • 46. PIC 18 has two to five timers depending on the family member- Timers 0, 1, 2, 3 and 4 ▪ Can be either used as timers to generate a time delay ▪ Or as counters to count events happening outside the microcontroller
  • 47. Basics Registers of the timer ▪Timers are 16-bit wide ◦Can be accessed as two separate reg. ◦Low Byte(TMRxL) & High Byte TMRxH) ◦Each timer also has TCON (timer Control) reg for setting modes of operation.