SlideShare a Scribd company logo
1 of 30
Download to read offline
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

More Related Content

What's hot

Tutorial dec0604(print24) Programming a PIC
Tutorial dec0604(print24) Programming a PICTutorial dec0604(print24) Programming a PIC
Tutorial dec0604(print24) Programming a PICMuhammad Khan
 
Lecture 1 - Introduction to embedded system and Robotics
Lecture 1 - Introduction to embedded system and RoboticsLecture 1 - Introduction to embedded system and Robotics
Lecture 1 - Introduction to embedded system and RoboticsVajira Thambawita
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontrollerSiva Kumar
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontrollerAshish Ranjan
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03Premier Farnell
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro ControllerMidhu S V Unnithan
 
Pic microcontrollers for_beginners
Pic microcontrollers for_beginnersPic microcontrollers for_beginners
Pic microcontrollers for_beginnersPraveen Chary
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]gauravholani
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller reviewMohsen Sarakbi
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877AMohamed Bedair
 
Pe 3231 week 15 18 plc
Pe 3231 week 15 18  plcPe 3231 week 15 18  plc
Pe 3231 week 15 18 plcCharlton Inao
 
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
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
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
 

What's hot (20)

Tutorial dec0604(print24) Programming a PIC
Tutorial dec0604(print24) Programming a PICTutorial dec0604(print24) Programming a PIC
Tutorial dec0604(print24) Programming a PIC
 
Lecture 1 - Introduction to embedded system and Robotics
Lecture 1 - Introduction to embedded system and RoboticsLecture 1 - Introduction to embedded system and Robotics
Lecture 1 - Introduction to embedded system and Robotics
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
 
Microchip's PIC Micro Controller
Microchip's PIC Micro ControllerMicrochip's PIC Micro Controller
Microchip's PIC Micro Controller
 
Pic microcontrollers for_beginners
Pic microcontrollers for_beginnersPic microcontrollers for_beginners
Pic microcontrollers for_beginners
 
PIC
PICPIC
PIC
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
 
PIC microcontroller review
PIC microcontroller reviewPIC microcontroller review
PIC microcontroller review
 
Analog I/O in PIC16F877A
Analog I/O in PIC16F877AAnalog I/O in PIC16F877A
Analog I/O in PIC16F877A
 
Pe 3231 week 15 18 plc
Pe 3231 week 15 18  plcPe 3231 week 15 18  plc
Pe 3231 week 15 18 plc
 
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
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
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
 
01. B.E.EEE.pdf
01. B.E.EEE.pdf01. B.E.EEE.pdf
01. B.E.EEE.pdf
 
PLC TRAINING
PLC TRAININGPLC TRAINING
PLC TRAINING
 

Viewers also liked (10)

Lecture 2 timers, pwm, state machine IN PIC
Lecture 2   timers, pwm, state machine IN PIC Lecture 2   timers, pwm, state machine IN PIC
Lecture 2 timers, pwm, state machine IN PIC
 
Lecture 1 microcontroller overview
Lecture 1   microcontroller overviewLecture 1   microcontroller overview
Lecture 1 microcontroller overview
 
Lecture 4 i2 c bus & interrupts
Lecture 4   i2 c bus & interruptsLecture 4   i2 c bus & interrupts
Lecture 4 i2 c bus & interrupts
 
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
 
VEHICLE ROLLOVER ANALYSIS
VEHICLE ROLLOVER ANALYSISVEHICLE ROLLOVER ANALYSIS
VEHICLE ROLLOVER ANALYSIS
 
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 to Lecture 4 i2 c bus & interrupts

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
 
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
 
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
 
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
 
Research Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and ScienceResearch Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and Scienceresearchinventy
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28rajeshkvdn
 

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

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
 
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
 
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
 
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...
 
Research Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and ScienceResearch Inventy: International Journal of Engineering and Science
Research Inventy: International Journal of Engineering and Science
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

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