SlideShare a Scribd company logo
1 of 39
PIC MICROCONTROLLER
PROGRAMMING
BASED ON MIKROC
Difference from A
microprocessor?
โ€ข To communicate microprocessor with
peripheral environment, special circuits must
be used.
Internal Structure
Description
โ€ข PIC โ€“ โ€œPeripheral Interface Controllerโ€
โ€ข Made by Microchip Technology
โ€ข Most popular by industry developers and
hobbyists
โ€“ Low cost (cents to dollars)
โ€“ Availability
โ€“ Extensive application notes
โ€“ Serial programming
4
Internal Units description
REGISTER
โ€ข An electronic circuit which can memorize the
state of one byte
SFR(Special Function Register)
โ€ข Registers whose function is predetermined by
the manufacturer of the microcontroller
โ€ข Examples are timers, A/D converter,
oscillators ,etc
INPUT / OUTPUT PORTS
โ€ข Microcontroller has one or more registers
(called ports) connected to the microcontroller
pins.
โ€ข Can change a pin function as you wish
MEMORY UNIT
โ€ข Memory is part of the microcontroller used for
data storage.
โ€ข Types
1.MROM,
2.OTP ROM, 3.UV EP
ROM, 4.FLASH MEM
5. EEPROM, 6. RAM
INTERRUPT
โ€ข Most programs use interrupts in their regular
execution
โ€ข The signal which informs the central processor
unit about such an event is called an
INTERRUPT.
CENTRAL PROCESSOR UNIT (CPU)
โ€ข Instruction decoder decodes program
instructions and runs other circuits based on
this
โ€ข Accumulator is a kind of working desk used
for storing all data upon which some
operation should be performed (addition,
shift/move etc.)
โ€ข ALU
OSCILLATOR
โ€ข Enable harmonic and synchronous operation of
all circuits within the microcontroller.
โ€ข Usually configured so as to use quartz crystal or
ceramic resonator for frequency stability
โ€ข but it can also operate as a stand-alone circuit
(like RC oscillator).
TIMERS/COUNTERS
โ€ข To measure time between two events, it is
sufficient to count up pulses generated by the
oscillator. This is exactly what the timer does.
โ€ข โ€˜Stopwatchesโ€™ commonly 8- or 16-bit SFRs the
contents of which is automatically incremented
by each coming pulse.
HOW DOES THE TIMER OPERATE?
โ€ข It is easy to measure short time intervals, up to
256 microsecond in this mode
โ€ขTo measure time intervals greater than 256 micro
size we use two modified methods
Using a pre Scaler
Using
Interrupt
COUNTERS
โ€ข If the timer receives pulses form the
microcontroller input pin, then it turns into a
counter.
โ€ข The only difference is that in this case pulses
to be counted come over the microcontroller
input pin and their duration (width) is mostly
undefined.
A/D CONVERTER
โ€ข Converts continuous signals to discrete digital
numbers or circuit converts an analogue value
into a binary number and passes it to the CPU
for further processing.
Basic path of processing codes
Tools required for programming
โ€ข Micro C IDE
โ€ข USB PIC Programmer drivers
โ€ข USB PIC Programmer
IDE FOR MIKROC PRO FOR PIC
โ€ข HNKKKKHH
COMPILERโ€™S TOOLS AND LIBRARIES
โ€ข USART TERMINAL
โ€ข EEPROM EDITOR
โ€ข ASCII CHART
โ€ข SEVEN SEGMENT EDITOR
โ€ข LCD CUSTOM CHARACTER
โ€ข GRAPHIC LCD BITMAP GENERATOR
โ€ข LIBRARIES
SEVEN SEGMENT EDITOR
PIC 16F877A LAYOUT
Analog I/O
UART
I2C
PORTA
http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-
world-of-microcontrollers/
24
FEATURES OF PIC 16F887A
โ€ข RISC architecture
โ€“ Only 35 instructions to learn
โ€“ All single-cycle instructions except branches
โ€ข Operating frequency 0-20 MHz
โ€ข Precision internal oscillator
โ€“ Factory calibrated
โ€“ Software selectable frequency range of 8MHz to 31KHz
โ€ข Power supply voltage 2.0-5.5V
โ€“ Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA
(stand-by mode)
โ€ข Power-Saving Sleep Mode
โ€ข Brown-out Reset (BOR) with software control option
โ€ข 35 input/output pins
โ€“ High current source/sink for direct LED drive
โ€ข 256 bytes EEPROM memory
โ€“ Data can be written more than 1.000.000 times
โ€ข 368 bytes RAM memory
โ€ข A/D converter:
โ€“ 14-channels
โ€“ 10-bit resolution
โ€ข 3 independent timers/counters
โ€ข Watch-dog timer
โ€ข Analogue comparator module with
โ€“ Two analogue comparators
โ€“ Fixed voltage reference (0.6V)
โ€“ Programmable on-chip voltage reference
โ€ข PWM output steering control
โ€ข Enhanced USART module
โ€“ Supports RS-485, RS-232 and LIN2.0
โ€“ Auto-Baud Detect
โ€ข Master Synchronous Serial Port (MSSP)
โ€“ supports SPI and I2C mode
BASIC CONNECTION OF A PIC
Basic codes of MikroC
โ€ข TRISB=0; means that all the pins of PORTB is set
as output. If it is set as 1 then all the pins will be
configured as input.
โ€ข PORTB=0; means that all the pins of PORTB is
Logic low. If it is set as 1 then all the pins will be
set as Logic high state.
โ€ข ANSELA = 0; Configure PORTA pins as digital.
ANSELA = 0b00000101; Means that RA0/C12IN0-
and RA2/C2IN+ pins are analog inputs.
โ€ข ANSELH=0; Configure PORTB pins as digital.
โ€ข TRISC.F0 = 1; Makes 0th bit of PORTC Input
โ€ข TRISC.F5 = 0; Makes 5th bit of PORTC Output
โ€ข PORTB.F3 = 1; Makes 3ed bit of PORTB at Logic
High
โ€ข PORTB.F7 = 0; Makes 7th bit of PORTB at Logic
Low
Simple MikroC program for blinking an
LED
Interfacing DC Motor with PIC
Microcontroller using L293D
โ€ข Control Signals and Motor Status
RB0/IN1 RB2/IN2 Motor
Status LOW LOW Stops
LOW HIGH ANT-CLK
HIGH LOW CLK
HIGH HIGH CLK
CCP(Capture/Compare/PWM) Module
โ€ข Three modes-Capture, compare , PWM
โ€ข PWM
โ€ข Signals with varying duty cycle.
โ€ข Importance in power control circuits.
โ€ข /* In this example, PWM module is initialized and set to give a pulse train of 50%
dutycycle.
For this purpose, functions PWM1_Init(), PWM1_Start() and PWM1_Set_Duty()
are used.
All of them are already contained in the mikroC PRO for PIC PWM library and just
need to
be copied to the program. */
unsigned short duty_c; // Define variable duty_c
void initMain() {
ANSEL = ANSELH = 0; // All I/O pins are configured as digital
PORTC = TRISC = 0; // Initial state of port C output pins
PWM1_Init(5000); // PWM module initialization (5KHz)
}
void main() {
initMain();
duty_c = 127; // Initial value of duty-cycle
PWM1_Start(); // Start PWM1 module
PWM1_Set_Duty(duty_c); // Set PWM duty-cycle to 50%
...
SERIAL COMMUNICATION
MODULES
โ€ข EUSART
Enhanced Universal Synchronous Asynchronous
Receiver Transmitter (EUSART)module is a serial I/O
communication peripheral unit.
โ€ข also known as Serial
Communications Interface (SCI)
โ€ข contains all clock generators,
shift registers and data buffers
necessary to perform an input/output serial data
transfer
โ€ข In order to enable data transmission via
EUSART module it is necessary to define the
state of the following pins-RX , TX
โ€ข RX-Receiver
โ€ข TX-Transmitter
/* In this example, internal EUSART module is initialized and set to send back the
message immediately after receiving it. Baude rate is set to 9600 bps. The
program
uses UART library routines UART1_init(), UART1_Write_Text(),
UART1_Data_Ready(),
UART1_Write() and UART1_Read().*/
char uart_rd;
void main() {
ANSEL = ANSELH = 0; // Configure AN pins as digital
C1ON_bit = C2ON_bit = 0; // Disable comparators
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to become stable
UART1_Write_Text("Start");
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data back via UART
}`
}
END
BY

More Related Content

What's hot

8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware
Prof. Swapnil V. Kaware
ย 

What's hot (20)

Microprocessor
MicroprocessorMicroprocessor
Microprocessor
ย 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
ย 
Pentium iii
Pentium iiiPentium iii
Pentium iii
ย 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
ย 
01 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.201601 GPIO||General Purpose Input Output.2016
01 GPIO||General Purpose Input Output.2016
ย 
Module 1 - ARM 32 Bit Microcontroller
Module 1 - ARM 32 Bit Microcontroller Module 1 - ARM 32 Bit Microcontroller
Module 1 - ARM 32 Bit Microcontroller
ย 
History of microprocessors
History of microprocessorsHistory of microprocessors
History of microprocessors
ย 
Msp 430 architecture module 1
Msp 430 architecture module 1Msp 430 architecture module 1
Msp 430 architecture module 1
ย 
Uart
UartUart
Uart
ย 
ARM Microcontroller and Embedded Systems (17EC62) โ€“ ARM โ€“ 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) โ€“ ARM โ€“ 32 bit Microcontrol...ARM Microcontroller and Embedded Systems (17EC62) โ€“ ARM โ€“ 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) โ€“ ARM โ€“ 32 bit Microcontrol...
ย 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
ย 
Microprocessors
MicroprocessorsMicroprocessors
Microprocessors
ย 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
ย 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148
ย 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
ย 
MICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
MICROPROCESSOR & MICROCONTROLLER 8086,8051 NotesMICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
MICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
ย 
8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware
ย 
Presentation on 8086 microprocessor
Presentation on 8086 microprocessorPresentation on 8086 microprocessor
Presentation on 8086 microprocessor
ย 
PULSE CODE MODULATION (PCM)
PULSE CODE MODULATION (PCM)PULSE CODE MODULATION (PCM)
PULSE CODE MODULATION (PCM)
ย 
80486 and pentium
80486 and pentium80486 and pentium
80486 and pentium
ย 

Similar to PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS

microcontroller board ppt
microcontroller board pptmicrocontroller board ppt
microcontroller board ppt
shashank tiwari
ย 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
Vivek Venugopal
ย 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
gauravholani
ย 

Similar to PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS (20)

Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
ย 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
ย 
microcontroller board ppt
microcontroller board pptmicrocontroller board ppt
microcontroller board ppt
ย 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
ย 
Embedded systemsc
Embedded systemscEmbedded systemsc
Embedded systemsc
ย 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
ย 
Embedded systems and robotics by scmandota
Embedded systems and robotics by scmandotaEmbedded systems and robotics by scmandota
Embedded systems and robotics by scmandota
ย 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
ย 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
ย 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
ย 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
ย 
embedded system
embedded systemembedded system
embedded system
ย 
plc_scada.pptx
plc_scada.pptxplc_scada.pptx
plc_scada.pptx
ย 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
ย 
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 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
ย 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikar
ย 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
ย 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
ย 
Bluetooth Home Automation
Bluetooth Home AutomationBluetooth Home Automation
Bluetooth Home Automation
ย 

Recently uploaded

Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
sivaprakash250
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
ย 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
amitlee9823
ย 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
ย 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
KreezheaRecto
ย 

Recently uploaded (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
ย 
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
ย 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
ย 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
ย 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
ย 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
ย 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
ย 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
ย 
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night StandCall Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
Call Girls In Bangalore โ˜Ž 7737669865 ๐Ÿฅต Book Your One night Stand
ย 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
ย 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ย 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
ย 

PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS

  • 2. Difference from A microprocessor? โ€ข To communicate microprocessor with peripheral environment, special circuits must be used.
  • 4. Description โ€ข PIC โ€“ โ€œPeripheral Interface Controllerโ€ โ€ข Made by Microchip Technology โ€ข Most popular by industry developers and hobbyists โ€“ Low cost (cents to dollars) โ€“ Availability โ€“ Extensive application notes โ€“ Serial programming 4
  • 5. Internal Units description REGISTER โ€ข An electronic circuit which can memorize the state of one byte
  • 6. SFR(Special Function Register) โ€ข Registers whose function is predetermined by the manufacturer of the microcontroller โ€ข Examples are timers, A/D converter, oscillators ,etc
  • 7. INPUT / OUTPUT PORTS โ€ข Microcontroller has one or more registers (called ports) connected to the microcontroller pins. โ€ข Can change a pin function as you wish
  • 8. MEMORY UNIT โ€ข Memory is part of the microcontroller used for data storage. โ€ข Types 1.MROM, 2.OTP ROM, 3.UV EP ROM, 4.FLASH MEM 5. EEPROM, 6. RAM
  • 9. INTERRUPT โ€ข Most programs use interrupts in their regular execution โ€ข The signal which informs the central processor unit about such an event is called an INTERRUPT.
  • 10. CENTRAL PROCESSOR UNIT (CPU) โ€ข Instruction decoder decodes program instructions and runs other circuits based on this โ€ข Accumulator is a kind of working desk used for storing all data upon which some operation should be performed (addition, shift/move etc.) โ€ข ALU
  • 11. OSCILLATOR โ€ข Enable harmonic and synchronous operation of all circuits within the microcontroller. โ€ข Usually configured so as to use quartz crystal or ceramic resonator for frequency stability โ€ข but it can also operate as a stand-alone circuit (like RC oscillator).
  • 12. TIMERS/COUNTERS โ€ข To measure time between two events, it is sufficient to count up pulses generated by the oscillator. This is exactly what the timer does. โ€ข โ€˜Stopwatchesโ€™ commonly 8- or 16-bit SFRs the contents of which is automatically incremented by each coming pulse.
  • 13. HOW DOES THE TIMER OPERATE? โ€ข It is easy to measure short time intervals, up to 256 microsecond in this mode โ€ขTo measure time intervals greater than 256 micro size we use two modified methods
  • 14. Using a pre Scaler Using Interrupt
  • 15. COUNTERS โ€ข If the timer receives pulses form the microcontroller input pin, then it turns into a counter. โ€ข The only difference is that in this case pulses to be counted come over the microcontroller input pin and their duration (width) is mostly undefined.
  • 16. A/D CONVERTER โ€ข Converts continuous signals to discrete digital numbers or circuit converts an analogue value into a binary number and passes it to the CPU for further processing.
  • 17.
  • 18. Basic path of processing codes
  • 19. Tools required for programming โ€ข Micro C IDE โ€ข USB PIC Programmer drivers โ€ข USB PIC Programmer
  • 20.
  • 21. IDE FOR MIKROC PRO FOR PIC โ€ข HNKKKKHH
  • 22. COMPILERโ€™S TOOLS AND LIBRARIES โ€ข USART TERMINAL โ€ข EEPROM EDITOR โ€ข ASCII CHART โ€ข SEVEN SEGMENT EDITOR โ€ข LCD CUSTOM CHARACTER โ€ข GRAPHIC LCD BITMAP GENERATOR โ€ข LIBRARIES
  • 24. PIC 16F877A LAYOUT Analog I/O UART I2C PORTA http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1- world-of-microcontrollers/ 24
  • 25.
  • 26. FEATURES OF PIC 16F887A โ€ข RISC architecture โ€“ Only 35 instructions to learn โ€“ All single-cycle instructions except branches โ€ข Operating frequency 0-20 MHz โ€ข Precision internal oscillator โ€“ Factory calibrated โ€“ Software selectable frequency range of 8MHz to 31KHz โ€ข Power supply voltage 2.0-5.5V โ€“ Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA (stand-by mode) โ€ข Power-Saving Sleep Mode โ€ข Brown-out Reset (BOR) with software control option โ€ข 35 input/output pins โ€“ High current source/sink for direct LED drive
  • 27. โ€ข 256 bytes EEPROM memory โ€“ Data can be written more than 1.000.000 times โ€ข 368 bytes RAM memory โ€ข A/D converter: โ€“ 14-channels โ€“ 10-bit resolution โ€ข 3 independent timers/counters โ€ข Watch-dog timer โ€ข Analogue comparator module with โ€“ Two analogue comparators โ€“ Fixed voltage reference (0.6V) โ€“ Programmable on-chip voltage reference โ€ข PWM output steering control โ€ข Enhanced USART module โ€“ Supports RS-485, RS-232 and LIN2.0 โ€“ Auto-Baud Detect โ€ข Master Synchronous Serial Port (MSSP) โ€“ supports SPI and I2C mode
  • 29. Basic codes of MikroC โ€ข TRISB=0; means that all the pins of PORTB is set as output. If it is set as 1 then all the pins will be configured as input. โ€ข PORTB=0; means that all the pins of PORTB is Logic low. If it is set as 1 then all the pins will be set as Logic high state. โ€ข ANSELA = 0; Configure PORTA pins as digital. ANSELA = 0b00000101; Means that RA0/C12IN0- and RA2/C2IN+ pins are analog inputs. โ€ข ANSELH=0; Configure PORTB pins as digital.
  • 30. โ€ข TRISC.F0 = 1; Makes 0th bit of PORTC Input โ€ข TRISC.F5 = 0; Makes 5th bit of PORTC Output โ€ข PORTB.F3 = 1; Makes 3ed bit of PORTB at Logic High โ€ข PORTB.F7 = 0; Makes 7th bit of PORTB at Logic Low
  • 31. Simple MikroC program for blinking an LED
  • 32. Interfacing DC Motor with PIC Microcontroller using L293D โ€ข Control Signals and Motor Status RB0/IN1 RB2/IN2 Motor Status LOW LOW Stops LOW HIGH ANT-CLK HIGH LOW CLK HIGH HIGH CLK
  • 33.
  • 34. CCP(Capture/Compare/PWM) Module โ€ข Three modes-Capture, compare , PWM โ€ข PWM โ€ข Signals with varying duty cycle. โ€ข Importance in power control circuits.
  • 35. โ€ข /* In this example, PWM module is initialized and set to give a pulse train of 50% dutycycle. For this purpose, functions PWM1_Init(), PWM1_Start() and PWM1_Set_Duty() are used. All of them are already contained in the mikroC PRO for PIC PWM library and just need to be copied to the program. */ unsigned short duty_c; // Define variable duty_c void initMain() { ANSEL = ANSELH = 0; // All I/O pins are configured as digital PORTC = TRISC = 0; // Initial state of port C output pins PWM1_Init(5000); // PWM module initialization (5KHz) } void main() { initMain(); duty_c = 127; // Initial value of duty-cycle PWM1_Start(); // Start PWM1 module PWM1_Set_Duty(duty_c); // Set PWM duty-cycle to 50% ...
  • 36. SERIAL COMMUNICATION MODULES โ€ข EUSART Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART)module is a serial I/O communication peripheral unit. โ€ข also known as Serial Communications Interface (SCI) โ€ข contains all clock generators, shift registers and data buffers necessary to perform an input/output serial data transfer
  • 37. โ€ข In order to enable data transmission via EUSART module it is necessary to define the state of the following pins-RX , TX โ€ข RX-Receiver โ€ข TX-Transmitter
  • 38. /* In this example, internal EUSART module is initialized and set to send back the message immediately after receiving it. Baude rate is set to 9600 bps. The program uses UART library routines UART1_init(), UART1_Write_Text(), UART1_Data_Ready(), UART1_Write() and UART1_Read().*/ char uart_rd; void main() { ANSEL = ANSELH = 0; // Configure AN pins as digital C1ON_bit = C2ON_bit = 0; // Disable comparators UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to become stable UART1_Write_Text("Start"); while (1) { // Endless loop if (UART1_Data_Ready()) { // If data is received, uart_rd = UART1_Read(); // read the received data, UART1_Write(uart_rd); // and send data back via UART }` }