SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Using Timer2/4/8 of Microchip PIC18F
Microcontrollers
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems Laboratory
Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy
santoro@dmi.unict.it
L.A.P. 1 Course
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
The other timers of of PIC18
In addition to TIMER0, PIC18 Family has other 6 timers, subdivided in
two families
First family includes TIMER1, TIMER3 and TIMER5
Second family includes TIMER2, TIMER4 and TIMER6
Timers of the same family have the same structure and working scheme
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
The timers 2/4/6 of of PIC18
Timers2/4/6 are 8-bit timers with period register;
Clock source can be only Fosc/4;
A prescaler is present and performs division by 1, 4 or 16;
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Working scheme of timers 2/4/6
TMRx increments according to clock source and prescaler;
When TMRx becomes equal to PRx, the internal EQ event is
generated
The EQ event causes an automatic reset to 0 of TIMERx;
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Working scheme of timers 2/4/6
The EQ event goes through the postscaler;
The postscaler counts for n EQ events, with 1 ≤ n ≤ 16 programmable,
and then activates TMRxIF.
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Special Functions Registers of timers 2/4/6
TxCON: Controls Prescaler and Postscaler
TMRx: The timer count variable
PRx: The timer period register
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Control Register of timers 2/4/6
TxOUTPS: Postscaler setup
0000 = 1:1 postscaler
0001 = 1:2 postscaler
...
1110 = 1:15 postscaler
1111 = 1:16 postscaler
TMRxON: Timer On/Off control
TxCKPS: Prescaler setup
00 = 1:1 prescaler
01 = 1:4 prescaler
1x = 1:16 prescaler
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Interrupt flags of timers 2/4/6
Interrupt (period-match) flags of timers 2/4/6 belong to various
special function registers:
TMR2IF ⇒ PIR1bits.TMR2IF
TMR4IF ⇒ PIR5bits.TMR4IF
TMR6IF ⇒ PIR5bits.TMR6IF
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Times and Prescalers
With Fosc/4 = 16MHz, 4 · Posc = 62.5ns:
TxCKPS = 1:1, bit period = 62.5ns, max period = 255 ∗ 62.5 = 15.9µs;
TxCKPS = 1:4, bit period = 250ns, max period =
255 ∗ 62.5 ∗ 4 = 63.75µs;
TxCKPS = 1:16, bit period = 1µs, max period = 256 ∗ 62.5 ∗ 4 = 255µs;
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
Using Timer2/4/8 of Microchip PIC18F
Microcontrollers
Corrado Santoro
ARSLAB - Autonomous and Robotic Systems Laboratory
Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy
santoro@dmi.unict.it
L.A.P. 1 Course
Corrado Santoro Using Timer2/4/8 in PIC18F MCUs

Contenu connexe

Tendances (20)

Ccp
CcpCcp
Ccp
 
UART MCU
UART MCUUART MCU
UART MCU
 
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
 
Soc
SocSoc
Soc
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programming
 
Avr timers
Avr timersAvr timers
Avr timers
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Timer & Interrupt Atmega16
Timer & Interrupt Atmega16Timer & Interrupt Atmega16
Timer & Interrupt Atmega16
 
8051 Timers / Counters
8051 Timers / Counters8051 Timers / Counters
8051 Timers / Counters
 
9 timer programming
9 timer programming9 timer programming
9 timer programming
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counters
 
Class9
Class9Class9
Class9
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
8051 timer counter
8051 timer counter8051 timer counter
8051 timer counter
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counters
 
Timers
TimersTimers
Timers
 
Ec8791 lpc2148 timer unit
Ec8791 lpc2148 timer unitEc8791 lpc2148 timer unit
Ec8791 lpc2148 timer unit
 
Programming 8051 Timers
Programming 8051 Timers Programming 8051 Timers
Programming 8051 Timers
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
Timers
TimersTimers
Timers
 

Similaire à Using Timer2 in Microchip MCUs

moving message display of lcd
 moving message display of lcd moving message display of lcd
moving message display of lcdabhishek upadhyay
 
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
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking Systemtheijes
 
Timers done by Priyanga KR
Timers done by Priyanga KRTimers done by Priyanga KR
Timers done by Priyanga KRPriyangaKR1
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptxSujalKumar73
 
Unit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxUnit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxnaveen088888
 
Hoja de datos del PIC16FX
Hoja de datos del PIC16FXHoja de datos del PIC16FX
Hoja de datos del PIC16FXconalep
 
Datasheet
DatasheetDatasheet
Datasheetconalep
 
Hoja de datos técnicos del PIC16FX
Hoja de datos técnicos del PIC16FXHoja de datos técnicos del PIC16FX
Hoja de datos técnicos del PIC16FXemmanuel9393
 
lecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptlecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptHebaEng
 
Timer And Counter in 8051 Microcontroller
Timer And Counter in 8051 MicrocontrollerTimer And Counter in 8051 Microcontroller
Timer And Counter in 8051 MicrocontrollerJay Makwana
 
micro controllers 1.ppt
micro controllers 1.pptmicro controllers 1.ppt
micro controllers 1.pptsiminkhan
 

Similaire à Using Timer2 in Microchip MCUs (20)

moving message display of lcd
 moving message display of lcd moving message display of lcd
moving message display of lcd
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 
Arduino 101
Arduino 101Arduino 101
Arduino 101
 
8051e
8051e8051e
8051e
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking System
 
Timers done by Priyanga KR
Timers done by Priyanga KRTimers done by Priyanga KR
Timers done by Priyanga KR
 
Timer 2 concept
Timer 2 conceptTimer 2 concept
Timer 2 concept
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptx
 
Unit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptxUnit 3 timer and counter and there application .pptx
Unit 3 timer and counter and there application .pptx
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Hoja de datos del PIC16FX
Hoja de datos del PIC16FXHoja de datos del PIC16FX
Hoja de datos del PIC16FX
 
Datasheet
DatasheetDatasheet
Datasheet
 
Hoja de datos técnicos del PIC16FX
Hoja de datos técnicos del PIC16FXHoja de datos técnicos del PIC16FX
Hoja de datos técnicos del PIC16FX
 
lecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptlecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.ppt
 
Timer 0 concept
Timer 0 conceptTimer 0 concept
Timer 0 concept
 
Timer And Counter in 8051 Microcontroller
Timer And Counter in 8051 MicrocontrollerTimer And Counter in 8051 Microcontroller
Timer And Counter in 8051 Microcontroller
 
micro controllers 1.ppt
micro controllers 1.pptmicro controllers 1.ppt
micro controllers 1.ppt
 
Data Sheet PIC 16F84
Data Sheet PIC 16F84Data Sheet PIC 16F84
Data Sheet PIC 16F84
 

Plus de Corrado Santoro

Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Corrado Santoro
 
Pulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsPulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsCorrado Santoro
 
Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Corrado Santoro
 
Presentation @ WOA 2015
Presentation @ WOA 2015 Presentation @ WOA 2015
Presentation @ WOA 2015 Corrado Santoro
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterCorrado Santoro
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerCorrado Santoro
 
Introduction to microcontrollers
Introduction to microcontrollersIntroduction to microcontrollers
Introduction to microcontrollersCorrado Santoro
 
How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...Corrado Santoro
 
Integrating Cloud Services in Behaviour Programming for Autonomous Robots
Integrating Cloud Services in Behaviour  Programming for Autonomous RobotsIntegrating Cloud Services in Behaviour  Programming for Autonomous Robots
Integrating Cloud Services in Behaviour Programming for Autonomous RobotsCorrado Santoro
 
Reactive Autonomous System Programming using the PROFETA tool
Reactive Autonomous System Programming using the PROFETA toolReactive Autonomous System Programming using the PROFETA tool
Reactive Autonomous System Programming using the PROFETA toolCorrado Santoro
 

Plus de Corrado Santoro (14)

Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
Physical Flying Agents: Ummanned Aerial Vehicles Control, Coordination and Em...
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
 
Pulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUsPulse Width Modulation Signal Generation with MCUs
Pulse Width Modulation Signal Generation with MCUs
 
Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015Presentation @ Miniscuola WOA 2015
Presentation @ Miniscuola WOA 2015
 
Presentation @ WOA 2015
Presentation @ WOA 2015 Presentation @ WOA 2015
Presentation @ WOA 2015
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Pillole di C++
Pillole di C++Pillole di C++
Pillole di C++
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontroller
 
Introduction to microcontrollers
Introduction to microcontrollersIntroduction to microcontrollers
Introduction to microcontrollers
 
How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...How does a Quadrotor fly? A journey from physics, mathematics, control system...
How does a Quadrotor fly? A journey from physics, mathematics, control system...
 
Integrating Cloud Services in Behaviour Programming for Autonomous Robots
Integrating Cloud Services in Behaviour  Programming for Autonomous RobotsIntegrating Cloud Services in Behaviour  Programming for Autonomous Robots
Integrating Cloud Services in Behaviour Programming for Autonomous Robots
 
Reactive Autonomous System Programming using the PROFETA tool
Reactive Autonomous System Programming using the PROFETA toolReactive Autonomous System Programming using the PROFETA tool
Reactive Autonomous System Programming using the PROFETA tool
 

Dernier

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Dernier (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

Using Timer2 in Microchip MCUs

  • 1. Using Timer2/4/8 of Microchip PIC18F Microcontrollers Corrado Santoro ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 2. The other timers of of PIC18 In addition to TIMER0, PIC18 Family has other 6 timers, subdivided in two families First family includes TIMER1, TIMER3 and TIMER5 Second family includes TIMER2, TIMER4 and TIMER6 Timers of the same family have the same structure and working scheme Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 3. The timers 2/4/6 of of PIC18 Timers2/4/6 are 8-bit timers with period register; Clock source can be only Fosc/4; A prescaler is present and performs division by 1, 4 or 16; Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 4. Working scheme of timers 2/4/6 TMRx increments according to clock source and prescaler; When TMRx becomes equal to PRx, the internal EQ event is generated The EQ event causes an automatic reset to 0 of TIMERx; Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 5. Working scheme of timers 2/4/6 The EQ event goes through the postscaler; The postscaler counts for n EQ events, with 1 ≤ n ≤ 16 programmable, and then activates TMRxIF. Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 6. Special Functions Registers of timers 2/4/6 TxCON: Controls Prescaler and Postscaler TMRx: The timer count variable PRx: The timer period register Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 7. Control Register of timers 2/4/6 TxOUTPS: Postscaler setup 0000 = 1:1 postscaler 0001 = 1:2 postscaler ... 1110 = 1:15 postscaler 1111 = 1:16 postscaler TMRxON: Timer On/Off control TxCKPS: Prescaler setup 00 = 1:1 prescaler 01 = 1:4 prescaler 1x = 1:16 prescaler Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 8. Interrupt flags of timers 2/4/6 Interrupt (period-match) flags of timers 2/4/6 belong to various special function registers: TMR2IF ⇒ PIR1bits.TMR2IF TMR4IF ⇒ PIR5bits.TMR4IF TMR6IF ⇒ PIR5bits.TMR6IF Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 9. Times and Prescalers With Fosc/4 = 16MHz, 4 · Posc = 62.5ns: TxCKPS = 1:1, bit period = 62.5ns, max period = 255 ∗ 62.5 = 15.9µs; TxCKPS = 1:4, bit period = 250ns, max period = 255 ∗ 62.5 ∗ 4 = 63.75µs; TxCKPS = 1:16, bit period = 1µs, max period = 256 ∗ 62.5 ∗ 4 = 255µs; Corrado Santoro Using Timer2/4/8 in PIC18F MCUs
  • 10. Using Timer2/4/8 of Microchip PIC18F Microcontrollers Corrado Santoro ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Universit`a di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course Corrado Santoro Using Timer2/4/8 in PIC18F MCUs