SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Workshop
Project Pedagogy approach of
Microcontroller
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 1
Microcontroller
PTC Khadoury IUT Cachan
Palestinian Robotic Cup
4. I²C bus & interrupts
connecting and using an ultrasonic i²c sensor
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 2
PTC Khadoury IUT Cachan
Why do you need ultrasonic telemeter ?
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 3
Blanche neige accident.MOV
without telemeter with telemeter
valetpique.mov
jack &
Commands
Energy
I2C
PWM
Outputs
Digital
communication
peripherals Chopper
+ Motors
ultrasonic
telemeter
UART
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 4
LCD
Display
jack &
buttons
line info
Micro-
controller
Digital
Input
Analog to
digital
converter
Digital
outputs
Fast
counting
Inputs
Analog to
digital
converter
Infrared
sensors
Motors
encoders
position
info
Potentio-
meter
jack &
Commands
Energy
I2C
PWM
Outputs
Digital
communication
peripherals Chopper
+ Motors
ultrasonic
telemeter
UART
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 5
LCD
Display
jack &
buttons
line info
Micro-
controller
Digital
Input
Analog to
digital
converter
Digital
outputs
Fast
counting
Inputs
Analog to
digital
converter
Infrared
sensors
Motors
encoders
position
info
Potentio-
meter
4.1 The ultrasonic telemeter SRF08
4.2 I²C physical & protocol layers
4 I²C bus & interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 6
4.3 Using the telemeter by pooling
4.4 interrupts
4.5 Using the telemeter with interrupts
4.1 The ultrasonic telemeter SRF08
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 7
4.1 The ultrasonic telemeter SRF08
piezoelectric
emitter
physics principle
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 8
piezoelectric
receiver
d = c.t
distance (m)
sound speed
through the air (~340 m.s-1)
flight time (s)
4.1 The ultrasonic telemeter SRF08
internals registers
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 9
initialization : 1 meter and result in centimeter
Measurement request
Waiting for 10 ms
Read result (between 0 and 100)
4.1 The ultrasonic telemeter SRF08
1
2
3
4
I2C
Header 4
SCL
SDA
VDD
connections
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 10
Header 4
SRF08 sensor pins
Microcontroller board
I²C connector
for more details, see www.robot-electronics.co.uk
4.2 I²C physical & protocol layers
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 11
4.2 I²C physical and protocol layers
I²C overview
Inter Integrated Circuits bus
2-wires synchronous bus
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 12
Up to 15 Mbits/s
Multi-master mode is possible
Up to 127 devices on the bus
4.2 I²C physical and protocol layers
physical layer : 2-wires synchronous bus
Sensor
(slave mode)
Memory
(slave mode)
Microcontroller
(Master Mode)
Real Time
Clock
(slave mode)
addr = 0xE0addr = 0xAC addr = 0xB4
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 13
GND
VCC = 5V
pull-up resistors
SCL (clock wire)
SDA (data wire)
4.2 I²C physical and protocol layers
frames
Transmit address
of Slave (W) Ack
Transmit register
number to write
Transmit data StopStart
frame to write
Sensor
(slave mode)
address 0xE0
Microcontroller
(Master Mode)
Ack Ack
Write address 0xE0
Read address 0xE1
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 14
GND
pull-up resistors
SCL (clock wire)
SDA (data wire)
address 0xE0
4.2 I²C physical and protocol layers
frames
Transmit address
of Slave (W)
Transmit register
number to read
Receive register
data from Slave
Start
frame to read
Transmit address
of Slave (R)
ReStart Stop
Sensor
(slave mode)
address 0xE0
Microcontroller
(Master Mode)
Ack Ack
Ack NAck
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 15
GND
pull-up resistors
SCL (clock wire)
SDA (data wire)
address 0xE0
(Master Mode)
4.2 I²C physical and protocol layers
For more details,
see I2C_BUS_SPECIFICATION_3.pdf
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 16
see I2C_BUS_SPECIFICATION_3.pdf
4.3 Using the telemeter by polling
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 17
4.3 Using the telemeter by polling
I²C configuration
See - Microchip PIC18F4550 datasheet (ch. 19)
- Microchip C18 library
SSPADD = 118;
OpenI2C(MASTER,SLEW_ON);
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 18
configure I²C peripheral
(Master and 400 kHz mode)
initialization : 1 meter and result in centimeter
Measurement request
Waiting for 10 ms
Read result
4.3 Using telemeter by polling
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 19
Read result
void SRF_initialisation(char address);
unsigned char SRF_read_byte( unsigned char address, unsigned char reg );
unsigned char SRF_write_byte( unsigned char address, unsigned char reg,
unsigned char data );
library SRF08
Timer3
4.4 Interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 20
4.4 Interrupts
4.5 Interrupts
What is an interrupt ?
Measurement request
Waiting for 10 ms
Read result
initialization
main program
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 21
measurement
request
CPU
occupation
CPU is reading
the value of the timer3
read
result
CPU is reading
the value of the timer3
measurement
request
read
result
…
4.5 Interrupts
What is an interrupt ?
initialization
Measurement request
Read result
main program interrupt subroutine
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 22
measurement
request
CPU
occupation
read
result
measurement
request
read
result
…the CPU is free the CPU is free
4.5 Interrupts
interrupt in Microchip PIC18Fxxxx
different interrupt sources :
- Timers
- External pins
- USART / USB / I2C
- …
for each interrupt source, 2 bits :
- One Flag bit
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 23
- One Flag bit
- One Enable bit
and sometimes
- One Priority bit
and, for all interrupts :
Two bits :
- GIE (Global interrupt enable)
- PEIE (Peripherals Interrupt enable)
Peripheral Interrupt Enable registers (PIE1 and PIE2).
PIE1 = 0b00000000;
SPPIE ADIE TXIE TMR2IE TMR1IESSPIERCIE CCP1IE
4.5 Interrupts
interrupt in Microchip PIC18Fxxxx
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 24
PIE2 = 0b00000010;
OSCFIE CMIE EEIE TMR3IE CCP2IEBCLIE
SPPIE ADIE TXIE TMR2IE TMR1IESSPIERCIE CCP1IE
USBIE HLVDIE
Peripheral Interrupt Request (Flag) registers (PIR1 and PIR2).
PIR1 = 0b00000000;
SPPIF ADIF TXIF TMR2IF TMR1IFSSPIFRCIF CCP1IF
interrupt in Microchip PIC18Fxxxx
4.5 Interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 25
PIR2 = 0b00000000;
OSCFIF CMIF EEIF TMR3IF CCP2IFBCLIF
SPPIF ADIF TXIF TMR2IF TMR1IFSSPIFRCIF CCP1IF
USBIF HLVDIF
What happens when an interrupt occurs ?
interrupt in Microchip PIC18Fxxxx
4.5 Interrupts
The program executes the instruction
which is at the address 0x08 in the
program memory
Program
counter goto Interrupt funct
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 26
main program
Interrupt function
Program
counterProgram
counter
Program
counter
Program
counter
Program
counter
4.5 Using the telemeter with interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 27
Flow chart
initialization
Measurement request
Read result
main program interrupt subroutine
4.5 Using the telemeter with interrupts
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 28
measurement
request
CPU
occupation
read
result
measurement
request
read
result
…the CPU is free the CPU is free
4.5 Using the telemeter with interrupts
1st : initialize the I²C bus and the sensor
3rd : unmask the interrupts you need (TMR3IE)
2nd : configure Timer3 (OpenTimer3(…))
4th : unmask interrupts (GIE and PEIE)
5th : write the infinite loop
main program
Interrupt subroutine
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 29
6th : write the interruption subroutine (Reading value & measurement request)
Interrupt subroutine
7th : write the declaration of this ISR on top of main file
8th : write the branch to go to this ISR
4.5 Using the telemeter with interrupts
Interrupt subroutine
6th : write the interruption subroutine (Reading value & measurement request)
#pragma interrupt TMR3_Interrupt_function
void TMR3_Interrupt_function(void)
{
if (PIR2bits.TMR3IF == 1)
{... }//end if
)// end TMR3_Interrupt_function
it indicates that the
following function is
an ISR
it verifies if this is
the timer3 which set
on the interrupt
Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 30
)// end TMR3_Interrupt_function
8th : write the branch to go to this ISR
#pragma code high_vector=0x08
void high_vector (void)
{ _asm goto TMR3_Interrupt_function _endasm }
#pragma code
it indicates that the next
code is at the adress 0x08
it indicates that the next
code is in the program memory
_asm and _endasm frame
an asm instruction
on the interrupt

Más contenido relacionado

La actualidad más candente

Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manualArun Shan
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailedAnkita Tiwari
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877AMohamed Bedair
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mappingOsaMa Hasan
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]gauravholani
 
Pic microcontrollers for_beginners
Pic microcontrollers for_beginnersPic microcontrollers for_beginners
Pic microcontrollers for_beginnersPraveen Chary
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDsunil polo
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cZakaria Gomaa
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller reviewMohsen Sarakbi
 
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 raikarGauravRaikar3
 
Microcontroller lec 2
Microcontroller  lec 2Microcontroller  lec 2
Microcontroller lec 2Ibrahim Reda
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 

La actualidad más candente (20)

Pic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guidePic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guide
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manual
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
An introdution to MPLAB
An introdution to MPLABAn introdution to MPLAB
An introdution to MPLAB
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877A
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
 
Pic microcontrollers for_beginners
Pic microcontrollers for_beginnersPic microcontrollers for_beginners
Pic microcontrollers for_beginners
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCD
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-c
 
Intrerfacing i
Intrerfacing iIntrerfacing i
Intrerfacing i
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller review
 
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 lec 2
Microcontroller  lec 2Microcontroller  lec 2
Microcontroller lec 2
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 

Destacado (8)

VEHICLE ROLLOVER ANALYSIS
VEHICLE ROLLOVER ANALYSISVEHICLE ROLLOVER ANALYSIS
VEHICLE ROLLOVER ANALYSIS
 
Lecture 1 microcontroller overview
Lecture 1   microcontroller overviewLecture 1   microcontroller overview
Lecture 1 microcontroller overview
 
Braking performance 4
Braking  performance 4Braking  performance 4
Braking performance 4
 
The Uses of Nanosensors: From Smart Dust to Nano “Mother Ships”
The Uses of Nanosensors: From Smart Dust to Nano “Mother Ships”The Uses of Nanosensors: From Smart Dust to Nano “Mother Ships”
The Uses of Nanosensors: From Smart Dust to Nano “Mother Ships”
 
Hydrolic Fluid purpose & properties (chapter 2)
Hydrolic Fluid purpose & properties (chapter 2)Hydrolic Fluid purpose & properties (chapter 2)
Hydrolic Fluid purpose & properties (chapter 2)
 
Single phase im-lecture_10_1
Single phase im-lecture_10_1Single phase im-lecture_10_1
Single phase im-lecture_10_1
 
Hydraulic pumps performance and Characteristics
Hydraulic pumps performance and CharacteristicsHydraulic pumps performance and Characteristics
Hydraulic pumps performance and Characteristics
 
Sensors, Proximity sensors. Optical – Through-beam, Optical - Diffuse
Sensors, Proximity sensors. Optical – Through-beam, Optical - DiffuseSensors, Proximity sensors. Optical – Through-beam, Optical - Diffuse
Sensors, Proximity sensors. Optical – Through-beam, Optical - Diffuse
 

Similar a Lecture 4 i2 c bus & interrupts

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
 
Scaling Down Instrumentation Deploying Analog Mixed Signal Technology
Scaling Down Instrumentation Deploying Analog Mixed Signal TechnologyScaling Down Instrumentation Deploying Analog Mixed Signal Technology
Scaling Down Instrumentation Deploying Analog Mixed Signal TechnologyShivaprasad Tilekar
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An IntroductionDilum Bandara
 
3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_archchandrika
 
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLING
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLINGINPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLING
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLINGASHOKKUMAR RAMAR
 
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAI
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAIE&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAI
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAIASHOKKUMAR RAMAR
 
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAINING
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAININGEEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAINING
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAININGASHOKKUMAR RAMAR
 
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAI
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAIECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAI
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAIASHOKKUMAR RAMAR
 
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECH
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECHCSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECH
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECHASHOKKUMAR RAMAR
 
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCAD
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCADINPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCAD
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCADASHOKKUMAR RAMAR
 
intelligent braking system report
intelligent braking system reportintelligent braking system report
intelligent braking system reportSumit Kumar
 
8051Architecture_Basics.pptx
8051Architecture_Basics.pptx8051Architecture_Basics.pptx
8051Architecture_Basics.pptxPallaviHailkar
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manualDhaval Shukla
 
Inception Institute of Industrial Training Brochure 2014 by APRM
Inception Institute of Industrial Training Brochure 2014 by APRMInception Institute of Industrial Training Brochure 2014 by APRM
Inception Institute of Industrial Training Brochure 2014 by APRMATHAL Public Relations & Marketing
 
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware Design
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware DesignPramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware Design
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware DesignPramod Jangam
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerRup Chowdhury
 
Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...researchinventy
 

Similar a Lecture 4 i2 c bus & interrupts (20)

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
 
Scaling Down Instrumentation Deploying Analog Mixed Signal Technology
Scaling Down Instrumentation Deploying Analog Mixed Signal TechnologyScaling Down Instrumentation Deploying Analog Mixed Signal Technology
Scaling Down Instrumentation Deploying Analog Mixed Signal Technology
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch3 embedded gr_ppapag_msp430_arch
3 embedded gr_ppapag_msp430_arch
 
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLING
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLINGINPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLING
INPLANT TRAINING IN CHENNAI-ROBOTICS/EMBEDDED SYSTEMS/PCB ASSEMBLING
 
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAI
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAIE&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAI
E&I INPLANT TRAINING-INSTRUMENTAION INPL;ANT TRAINING CHENNAI
 
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAINING
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAININGEEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAINING
EEE INPLANT TRAINING IN CHENNAI-ELECTRICAL INPLANT TRAINING
 
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAI
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAIECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAI
ECE INPLANT TRAINING IN EMBEDDED SYSTEMS CHENNAI
 
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECH
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECHCSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECH
CSE INPLANT TRAINING FOR CSE/IT STUDENTS-CHENNAI MAASTECH
 
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCAD
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCADINPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCAD
INPLANT TRAINING IN ROBOTICS/EMBEDDED SYSTEMS/PCB DESIGNING/ORCAD
 
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGSA STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
 
intelligent braking system report
intelligent braking system reportintelligent braking system report
intelligent braking system report
 
8051Architecture_Basics.pptx
8051Architecture_Basics.pptx8051Architecture_Basics.pptx
8051Architecture_Basics.pptx
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manual
 
Inception Institute of Industrial Training Brochure 2014 by APRM
Inception Institute of Industrial Training Brochure 2014 by APRMInception Institute of Industrial Training Brochure 2014 by APRM
Inception Institute of Industrial Training Brochure 2014 by APRM
 
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware Design
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware DesignPramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware Design
Pramod J Resume M.Sc. (Electronics) 3.5 Year Exprience in Hardware Design
 
Overview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontrollerOverview of Microcontroller and ATMega32 microcontroller
Overview of Microcontroller and ATMega32 microcontroller
 
Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...Research Inventy : International Journal of Engineering and Science is publis...
Research Inventy : International Journal of Engineering and Science is publis...
 

Último

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 

Último (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Lecture 4 i2 c bus & interrupts

  • 1. Workshop Project Pedagogy approach of Microcontroller Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 1 Microcontroller PTC Khadoury IUT Cachan Palestinian Robotic Cup
  • 2. 4. I²C bus & interrupts connecting and using an ultrasonic i²c sensor Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 2 PTC Khadoury IUT Cachan
  • 3. Why do you need ultrasonic telemeter ? Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 3 Blanche neige accident.MOV without telemeter with telemeter valetpique.mov
  • 4. jack & Commands Energy I2C PWM Outputs Digital communication peripherals Chopper + Motors ultrasonic telemeter UART Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 4 LCD Display jack & buttons line info Micro- controller Digital Input Analog to digital converter Digital outputs Fast counting Inputs Analog to digital converter Infrared sensors Motors encoders position info Potentio- meter
  • 5. jack & Commands Energy I2C PWM Outputs Digital communication peripherals Chopper + Motors ultrasonic telemeter UART Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 5 LCD Display jack & buttons line info Micro- controller Digital Input Analog to digital converter Digital outputs Fast counting Inputs Analog to digital converter Infrared sensors Motors encoders position info Potentio- meter
  • 6. 4.1 The ultrasonic telemeter SRF08 4.2 I²C physical & protocol layers 4 I²C bus & interrupts Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 6 4.3 Using the telemeter by pooling 4.4 interrupts 4.5 Using the telemeter with interrupts
  • 7. 4.1 The ultrasonic telemeter SRF08 Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 7
  • 8. 4.1 The ultrasonic telemeter SRF08 piezoelectric emitter physics principle Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 8 piezoelectric receiver d = c.t distance (m) sound speed through the air (~340 m.s-1) flight time (s)
  • 9. 4.1 The ultrasonic telemeter SRF08 internals registers Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 9 initialization : 1 meter and result in centimeter Measurement request Waiting for 10 ms Read result (between 0 and 100)
  • 10. 4.1 The ultrasonic telemeter SRF08 1 2 3 4 I2C Header 4 SCL SDA VDD connections Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 10 Header 4 SRF08 sensor pins Microcontroller board I²C connector for more details, see www.robot-electronics.co.uk
  • 11. 4.2 I²C physical & protocol layers Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 11
  • 12. 4.2 I²C physical and protocol layers I²C overview Inter Integrated Circuits bus 2-wires synchronous bus Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 12 Up to 15 Mbits/s Multi-master mode is possible Up to 127 devices on the bus
  • 13. 4.2 I²C physical and protocol layers physical layer : 2-wires synchronous bus Sensor (slave mode) Memory (slave mode) Microcontroller (Master Mode) Real Time Clock (slave mode) addr = 0xE0addr = 0xAC addr = 0xB4 Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 13 GND VCC = 5V pull-up resistors SCL (clock wire) SDA (data wire)
  • 14. 4.2 I²C physical and protocol layers frames Transmit address of Slave (W) Ack Transmit register number to write Transmit data StopStart frame to write Sensor (slave mode) address 0xE0 Microcontroller (Master Mode) Ack Ack Write address 0xE0 Read address 0xE1 Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 14 GND pull-up resistors SCL (clock wire) SDA (data wire) address 0xE0
  • 15. 4.2 I²C physical and protocol layers frames Transmit address of Slave (W) Transmit register number to read Receive register data from Slave Start frame to read Transmit address of Slave (R) ReStart Stop Sensor (slave mode) address 0xE0 Microcontroller (Master Mode) Ack Ack Ack NAck Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 15 GND pull-up resistors SCL (clock wire) SDA (data wire) address 0xE0 (Master Mode)
  • 16. 4.2 I²C physical and protocol layers For more details, see I2C_BUS_SPECIFICATION_3.pdf Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 16 see I2C_BUS_SPECIFICATION_3.pdf
  • 17. 4.3 Using the telemeter by polling Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 17
  • 18. 4.3 Using the telemeter by polling I²C configuration See - Microchip PIC18F4550 datasheet (ch. 19) - Microchip C18 library SSPADD = 118; OpenI2C(MASTER,SLEW_ON); Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 18 configure I²C peripheral (Master and 400 kHz mode)
  • 19. initialization : 1 meter and result in centimeter Measurement request Waiting for 10 ms Read result 4.3 Using telemeter by polling Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 19 Read result void SRF_initialisation(char address); unsigned char SRF_read_byte( unsigned char address, unsigned char reg ); unsigned char SRF_write_byte( unsigned char address, unsigned char reg, unsigned char data ); library SRF08 Timer3
  • 20. 4.4 Interrupts Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 20 4.4 Interrupts
  • 21. 4.5 Interrupts What is an interrupt ? Measurement request Waiting for 10 ms Read result initialization main program Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 21 measurement request CPU occupation CPU is reading the value of the timer3 read result CPU is reading the value of the timer3 measurement request read result …
  • 22. 4.5 Interrupts What is an interrupt ? initialization Measurement request Read result main program interrupt subroutine Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 22 measurement request CPU occupation read result measurement request read result …the CPU is free the CPU is free
  • 23. 4.5 Interrupts interrupt in Microchip PIC18Fxxxx different interrupt sources : - Timers - External pins - USART / USB / I2C - … for each interrupt source, 2 bits : - One Flag bit Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 23 - One Flag bit - One Enable bit and sometimes - One Priority bit and, for all interrupts : Two bits : - GIE (Global interrupt enable) - PEIE (Peripherals Interrupt enable)
  • 24. Peripheral Interrupt Enable registers (PIE1 and PIE2). PIE1 = 0b00000000; SPPIE ADIE TXIE TMR2IE TMR1IESSPIERCIE CCP1IE 4.5 Interrupts interrupt in Microchip PIC18Fxxxx Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 24 PIE2 = 0b00000010; OSCFIE CMIE EEIE TMR3IE CCP2IEBCLIE SPPIE ADIE TXIE TMR2IE TMR1IESSPIERCIE CCP1IE USBIE HLVDIE
  • 25. Peripheral Interrupt Request (Flag) registers (PIR1 and PIR2). PIR1 = 0b00000000; SPPIF ADIF TXIF TMR2IF TMR1IFSSPIFRCIF CCP1IF interrupt in Microchip PIC18Fxxxx 4.5 Interrupts Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 25 PIR2 = 0b00000000; OSCFIF CMIF EEIF TMR3IF CCP2IFBCLIF SPPIF ADIF TXIF TMR2IF TMR1IFSSPIFRCIF CCP1IF USBIF HLVDIF
  • 26. What happens when an interrupt occurs ? interrupt in Microchip PIC18Fxxxx 4.5 Interrupts The program executes the instruction which is at the address 0x08 in the program memory Program counter goto Interrupt funct Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 26 main program Interrupt function Program counterProgram counter Program counter Program counter Program counter
  • 27. 4.5 Using the telemeter with interrupts Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 27
  • 28. Flow chart initialization Measurement request Read result main program interrupt subroutine 4.5 Using the telemeter with interrupts Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 28 measurement request CPU occupation read result measurement request read result …the CPU is free the CPU is free
  • 29. 4.5 Using the telemeter with interrupts 1st : initialize the I²C bus and the sensor 3rd : unmask the interrupts you need (TMR3IE) 2nd : configure Timer3 (OpenTimer3(…)) 4th : unmask interrupts (GIE and PEIE) 5th : write the infinite loop main program Interrupt subroutine Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 29 6th : write the interruption subroutine (Reading value & measurement request) Interrupt subroutine 7th : write the declaration of this ISR on top of main file 8th : write the branch to go to this ISR
  • 30. 4.5 Using the telemeter with interrupts Interrupt subroutine 6th : write the interruption subroutine (Reading value & measurement request) #pragma interrupt TMR3_Interrupt_function void TMR3_Interrupt_function(void) { if (PIR2bits.TMR3IF == 1) {... }//end if )// end TMR3_Interrupt_function it indicates that the following function is an ISR it verifies if this is the timer3 which set on the interrupt Project Pedagogy approach of Microcontroller – Palestinian Robotic Cup 30 )// end TMR3_Interrupt_function 8th : write the branch to go to this ISR #pragma code high_vector=0x08 void high_vector (void) { _asm goto TMR3_Interrupt_function _endasm } #pragma code it indicates that the next code is at the adress 0x08 it indicates that the next code is in the program memory _asm and _endasm frame an asm instruction on the interrupt