SlideShare a Scribd company logo
1 of 17
LPC 1768TIMERS
Done by
Priyanga KR
AP/ECE
Avinashilingam Institute
Timers
★ It has four 32-bit Timer blocks
★ Each Timer block can be used as a ‘Timer’ (like for e.g. triggering an interrupt every ‘t’
microseconds) or as a ‘Counter’ and can be also used to demodulate PWM signals
given as input.
★ Each Timer module has its own Timer Counter(TC) and Prescale Register(PR)
associated with it.
★ When a Timer is Reset and Enabled, the TC is set to 0 and incremented by 1 every
‘PR+1’ clock cycles
Contd...
★ Prescale Register is used to define the resolution of the timer.
★ If PR is 0 then TC is incremented every 1 clock cycle of the peripheral clock. If PR=1
then TC is incremented every 2 clock cycles of peripheral clock and so on.
★ Each Timer has four 32-bit Match Registers and four 32-bit Capture Registers.
★ Timer 0,1,3 have two Match outputs while Timer 2 has four.
Match Register
★ A Match Register is a Register which contains a specific value set by the user.
★ When the Timer starts – every time after TC is incremented the value in TC is
compared with match register.
★ If it matches then it can Reset the Timer or can generate an interrupt as defined by
the user.
Contd...
★ Stop Timer on Match(i.e when the value in count register is same as than in Match
register) and trigger an optional interrupt.
★ Reset Timer on Match and trigger an optional interrupt.
★ To count continuously and trigger an interrupt on match.
External Match Output
★ When a corresponding Match register(MRx) equals the Timer Counter(TC) the match
output can be controlled using External Match Register(EMR) to : either toggle, go
HIGH, go LOW or do nothing.
Capture Register
★ As the name suggests it is used to Capture Input signal.
★ When a transition event occurs on a Capture pin , it can be used to copy the value of
TC into any of the 4 Capture Register or to generate an Interrupt.
★ Hence these can be also used to demodulated PWM signals.
Timers -Block Diagram
Registers used for LPC1768Timer Programming
★ lpc17xx.h header file for programming.
★ In CMSIS, all the Registers used to program and use timers are defined as members
of structure(pointer) LPC_TIMx where x is the Timer module from 0 to 3.
★ So for Timer1 we will use LPC_TIM0 and so on. Registers can be accessed by de-
referecing the pointer using “->” operator.
★ For, example we can access TCR of Timer0 block as LPC_TIM0->TCR.
Contd...
1) PR: Prescale Register (32 bit) – Stores the maximum value of Prescale counter after
which it is reset.
2) PC: Prescale Counter Register (32 bit) – This register increments on every
PCLK(Peripheral clock). This register controls the resolution of the timer. When PC reaches
the value in PR , PC is reset back to 0 and Timer Counter is incremented by 1. Hence if
PR=0 then Timer Counter Increments on every 1 PCLK. If PR=9 then Timer Counter
Increments on every 10th cycle of PCLK. Hence by selecting an appropriate prescale value
we can control the resolution of the timer.
3) TC: Timer Counter Register (32 bit) – This is the main counting register. Timer Counter
increments when PC reaches its maximum value as specified by PR. If timer is not reset
explicitly(directly) or by using an interrupt then it will act as a free running counter which
resets back to zero when it reaches its maximum value which is 0xFFFFFFFF.
Contd...
4) TCR: Timer Control Register – This register is used to enable , disable and reset TC.
When bit0 is 1 timer is enabled and when 0 it is disabled. When bit1 is set to 1 TC and PC
are set to zero together in sync on the next positive edge of PCLK. Rest of the bits of TCR
are reserved.
5) CTCR: Count Control register – Used to select Timer/Counter Mode. For our purpose
we are always gonna use this in Timer Mode. When the value of the CTCR is set to 0x0
Timer Mode is selected.
Contd...
6) MCR: Match Control register – This register is used to control which all operations can
be done when the value in MR matches the value in TC. Bits 0,1,2 are for MR0 , Bits 3,4,5
for MR1 and so on.. Heres a quick table which shows the usage:
For MR0:
● Bit 0: Interrupt on MR0 i.e. trigger an interrupt when MR0 matches TC. Interrupts are
enabled when set to 1 and disabled when set to 0.
● Bit 1: Reset on MR0. When set to 1 , TC will be reset when it matched MR0. Disabled
when set to 0.
● Bit 2: Stop on MR0. When set to 1 , TC & PC will stop when MR0 matches TC.
Similarly bits 3-5 , 6-8 , 9-11 are for MR1 , MR2 , MR3 respectively.
Contd...
7) IR: Interrupt Register – It contains the interrupt flags for 4 match and 4 capture
interrupts. Bit0 to bit3 are for MR0 to MR3 interrupts respectively. And similarly the next 4
for CR0-3 interrupts. when an interrupt is raised the corresponding bit in IR will be set to 1
and 0 otherwise. Writing a 1 to the corresponding bit location will reset the interrupt –
which is used to acknowledge the completion of the corresponding ISR execution.
Contd...
8) EMR: External Match Register – It provides both status and control of External Match
Output Pins. First four bits are for EM0 to EM3. Next 8 bits are for EMC0 to EMC3 in pairs of
2.
● Bit 0 – EM0: External Match 0. When a match occurs between TC and MR0, depending
on bits[5:4] i.e. EMC0 of this register, this bit can either toggle, go LOW, go HIGH, or do
nothing. This bit is driven to MATx.0 where x=Timer number.
● Bits[5:4] – EMC0: External Match 0. The values in these bits select the functionality of
EM0 as follows:
○ 0x0 – Do nothing
○ 0x1 – Clear the corresponding External Match output to 0 (MATx.m pin is LOW).
○ 0x2 – Set the corresponding External Match output to 1 (MATx.m pin is HIGH).
○ 0x3 – Toggle the corresponding External Match output.
● Similarly for Bits[7:6] – EMC1, Bits[9,8] – EMC2, Bits[11:10] – EMC3.
LPC1768Timer Prescaler Calculations:
The delay or time required for 1 clock cycle when PCLK = ‘X’ Mhz is given by :
It is also the maximum resolution Timer block can proved at a given PCLK frequency of X
Mhz. The general formula for Timer resolution at X Mhz PCLK and a given value for
prescale (PR) is as given below:
Contd...
Hence, we get the Formula for Prescaler (PR) for required Timer resolution (TRES in
Secs) at given PCLK(in Hz) frequency as:
PR = (PCLKHz * TRES) – 1
PR = ((X * 106) * TRES) – 1
Note that here, the resolution is also the time delay required to increment TC by 1.
Contd...
Hence, Prescaler value for 1 micro-second resolution/ 1us time delay at 25 Mhz PCLK is,
Prescale for 1 mS (milli-second) resolution at 25Mhz PCLK is,
PR1ms = (25Mhz * 1ms) -1 = (25*106 * 10-3) -1 = 24999
The maximum resolution of all the timers is 10 nano-seconds when using PCLK = CCLK =
100Mhz and PR=0 which is as follows,
TMAXRES = [1 / (100Mhz)] = 10ns
PR1us = (25Mhz * 1uS) -1 = (25*106 * 10-6) -1 = 24

More Related Content

What's hot

What's hot (20)

ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
Interrupts at AVR
Interrupts at AVRInterrupts at AVR
Interrupts at AVR
 
Lpc1768
Lpc1768Lpc1768
Lpc1768
 
Unit 2 mpmc
Unit 2 mpmcUnit 2 mpmc
Unit 2 mpmc
 
ARM Fundamentals
ARM FundamentalsARM Fundamentals
ARM Fundamentals
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
8085 microproceesor ppt
8085 microproceesor ppt8085 microproceesor ppt
8085 microproceesor ppt
 
Microprocessor fundamentals
Microprocessor fundamentalsMicroprocessor fundamentals
Microprocessor fundamentals
 
AVRTIMER.pptx
AVRTIMER.pptxAVRTIMER.pptx
AVRTIMER.pptx
 
8086
80868086
8086
 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148
 
Introduction to 80386
Introduction to 80386Introduction to 80386
Introduction to 80386
 
Static and Dynamic Read/Write memories
Static and Dynamic Read/Write memoriesStatic and Dynamic Read/Write memories
Static and Dynamic Read/Write memories
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessor
 
USART
USARTUSART
USART
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
 

Similar to Lpc 1768 timers

Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Aarav Soni
 
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 programmingMohamed Ali
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 prsamurti
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptxSujalKumar73
 
Timer & Interrupt Atmega16
Timer & Interrupt Atmega16Timer & Interrupt Atmega16
Timer & Interrupt Atmega16Ramadan Ramadan
 
What isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationWhat isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationOmar BOUZOURRAA
 
MICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptMICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptreemasajin1
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming IIOmar Sanchez
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming IIOmar Sanchez
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming IIOmar Sanchez
 
LPC 1768 A study on Real Time clock features
LPC 1768 A study on Real Time clock featuresLPC 1768 A study on Real Time clock features
LPC 1768 A study on Real Time clock featuresOmkar Rane
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorialFutura infotech
 
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50Ruthvik Vaila
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfSPonmalar1
 

Similar to Lpc 1768 timers (20)

Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
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
 
L15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 pL15 timers-counters-in-atmega328 p
L15 timers-counters-in-atmega328 p
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptx
 
Timer & Interrupt Atmega16
Timer & Interrupt Atmega16Timer & Interrupt Atmega16
Timer & Interrupt Atmega16
 
8051 timers--2
   8051 timers--2   8051 timers--2
8051 timers--2
 
What isn’t told about timers in stm32 application
What isn’t told about timers in stm32 applicationWhat isn’t told about timers in stm32 application
What isn’t told about timers in stm32 application
 
MICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptMICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.ppt
 
Timers and pwm
Timers and pwmTimers and pwm
Timers and pwm
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
Assembly programming II
Assembly programming IIAssembly programming II
Assembly programming II
 
LPC 1768 A study on Real Time clock features
LPC 1768 A study on Real Time clock featuresLPC 1768 A study on Real Time clock features
LPC 1768 A study on Real Time clock features
 
8051 training an interactive tutorial
8051 training an interactive tutorial8051 training an interactive tutorial
8051 training an interactive tutorial
 
Lab5
Lab5Lab5
Lab5
 
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdf
 
Ec8791 lpc2148 timer unit
Ec8791 lpc2148 timer unitEc8791 lpc2148 timer unit
Ec8791 lpc2148 timer unit
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 

More from PriyangaKR1

Air conditioners
Air conditionersAir conditioners
Air conditionersPriyangaKR1
 
Ups and burglar alarm
Ups and burglar alarmUps and burglar alarm
Ups and burglar alarmPriyangaKR1
 
Supervisor call and pendable service call
Supervisor call and pendable service callSupervisor call and pendable service call
Supervisor call and pendable service callPriyangaKR1
 
Arm Development Tools
Arm Development ToolsArm Development Tools
Arm Development ToolsPriyangaKR1
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction setPriyangaKR1
 
Multimedia compression networks
Multimedia compression networksMultimedia compression networks
Multimedia compression networksPriyangaKR1
 
Trends and satellite
Trends and satelliteTrends and satellite
Trends and satellitePriyangaKR1
 
Mobile around the world and wireless communication examples
Mobile around the world and wireless communication examplesMobile around the world and wireless communication examples
Mobile around the world and wireless communication examplesPriyangaKR1
 
Mobile communication - Introduction
Mobile communication - IntroductionMobile communication - Introduction
Mobile communication - IntroductionPriyangaKR1
 
Real time operating systems
Real time operating systemsReal time operating systems
Real time operating systemsPriyangaKR1
 
Timers done by Priyanga KR
Timers done by Priyanga KRTimers done by Priyanga KR
Timers done by Priyanga KRPriyangaKR1
 
Instruction sets picc done by Priyanga KR
Instruction sets   picc done by Priyanga KRInstruction sets   picc done by Priyanga KR
Instruction sets picc done by Priyanga KRPriyangaKR1
 
Pic architecture done by Priyanga KR
Pic architecture done by Priyanga KRPic architecture done by Priyanga KR
Pic architecture done by Priyanga KRPriyangaKR1
 

More from PriyangaKR1 (20)

Lpc 17xx adc
Lpc 17xx adcLpc 17xx adc
Lpc 17xx adc
 
CCTV
CCTVCCTV
CCTV
 
Washing machine
Washing machineWashing machine
Washing machine
 
Rice cooker
Rice cookerRice cooker
Rice cooker
 
Refrigerators
RefrigeratorsRefrigerators
Refrigerators
 
Air conditioners
Air conditionersAir conditioners
Air conditioners
 
Microwave oven
Microwave ovenMicrowave oven
Microwave oven
 
Ups and burglar alarm
Ups and burglar alarmUps and burglar alarm
Ups and burglar alarm
 
Supervisor call and pendable service call
Supervisor call and pendable service callSupervisor call and pendable service call
Supervisor call and pendable service call
 
Arm Development Tools
Arm Development ToolsArm Development Tools
Arm Development Tools
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Multimedia compression networks
Multimedia compression networksMultimedia compression networks
Multimedia compression networks
 
Trends and satellite
Trends and satelliteTrends and satellite
Trends and satellite
 
Mobile around the world and wireless communication examples
Mobile around the world and wireless communication examplesMobile around the world and wireless communication examples
Mobile around the world and wireless communication examples
 
Mobile communication - Introduction
Mobile communication - IntroductionMobile communication - Introduction
Mobile communication - Introduction
 
Root locus tech
Root locus techRoot locus tech
Root locus tech
 
Real time operating systems
Real time operating systemsReal time operating systems
Real time operating systems
 
Timers done by Priyanga KR
Timers done by Priyanga KRTimers done by Priyanga KR
Timers done by Priyanga KR
 
Instruction sets picc done by Priyanga KR
Instruction sets   picc done by Priyanga KRInstruction sets   picc done by Priyanga KR
Instruction sets picc done by Priyanga KR
 
Pic architecture done by Priyanga KR
Pic architecture done by Priyanga KRPic architecture done by Priyanga KR
Pic architecture done by Priyanga KR
 

Recently uploaded

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 

Recently uploaded (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 

Lpc 1768 timers

  • 1. LPC 1768TIMERS Done by Priyanga KR AP/ECE Avinashilingam Institute
  • 2. Timers ★ It has four 32-bit Timer blocks ★ Each Timer block can be used as a ‘Timer’ (like for e.g. triggering an interrupt every ‘t’ microseconds) or as a ‘Counter’ and can be also used to demodulate PWM signals given as input. ★ Each Timer module has its own Timer Counter(TC) and Prescale Register(PR) associated with it. ★ When a Timer is Reset and Enabled, the TC is set to 0 and incremented by 1 every ‘PR+1’ clock cycles
  • 3. Contd... ★ Prescale Register is used to define the resolution of the timer. ★ If PR is 0 then TC is incremented every 1 clock cycle of the peripheral clock. If PR=1 then TC is incremented every 2 clock cycles of peripheral clock and so on. ★ Each Timer has four 32-bit Match Registers and four 32-bit Capture Registers. ★ Timer 0,1,3 have two Match outputs while Timer 2 has four.
  • 4. Match Register ★ A Match Register is a Register which contains a specific value set by the user. ★ When the Timer starts – every time after TC is incremented the value in TC is compared with match register. ★ If it matches then it can Reset the Timer or can generate an interrupt as defined by the user.
  • 5. Contd... ★ Stop Timer on Match(i.e when the value in count register is same as than in Match register) and trigger an optional interrupt. ★ Reset Timer on Match and trigger an optional interrupt. ★ To count continuously and trigger an interrupt on match.
  • 6. External Match Output ★ When a corresponding Match register(MRx) equals the Timer Counter(TC) the match output can be controlled using External Match Register(EMR) to : either toggle, go HIGH, go LOW or do nothing.
  • 7. Capture Register ★ As the name suggests it is used to Capture Input signal. ★ When a transition event occurs on a Capture pin , it can be used to copy the value of TC into any of the 4 Capture Register or to generate an Interrupt. ★ Hence these can be also used to demodulated PWM signals.
  • 9. Registers used for LPC1768Timer Programming ★ lpc17xx.h header file for programming. ★ In CMSIS, all the Registers used to program and use timers are defined as members of structure(pointer) LPC_TIMx where x is the Timer module from 0 to 3. ★ So for Timer1 we will use LPC_TIM0 and so on. Registers can be accessed by de- referecing the pointer using “->” operator. ★ For, example we can access TCR of Timer0 block as LPC_TIM0->TCR.
  • 10. Contd... 1) PR: Prescale Register (32 bit) – Stores the maximum value of Prescale counter after which it is reset. 2) PC: Prescale Counter Register (32 bit) – This register increments on every PCLK(Peripheral clock). This register controls the resolution of the timer. When PC reaches the value in PR , PC is reset back to 0 and Timer Counter is incremented by 1. Hence if PR=0 then Timer Counter Increments on every 1 PCLK. If PR=9 then Timer Counter Increments on every 10th cycle of PCLK. Hence by selecting an appropriate prescale value we can control the resolution of the timer. 3) TC: Timer Counter Register (32 bit) – This is the main counting register. Timer Counter increments when PC reaches its maximum value as specified by PR. If timer is not reset explicitly(directly) or by using an interrupt then it will act as a free running counter which resets back to zero when it reaches its maximum value which is 0xFFFFFFFF.
  • 11. Contd... 4) TCR: Timer Control Register – This register is used to enable , disable and reset TC. When bit0 is 1 timer is enabled and when 0 it is disabled. When bit1 is set to 1 TC and PC are set to zero together in sync on the next positive edge of PCLK. Rest of the bits of TCR are reserved. 5) CTCR: Count Control register – Used to select Timer/Counter Mode. For our purpose we are always gonna use this in Timer Mode. When the value of the CTCR is set to 0x0 Timer Mode is selected.
  • 12. Contd... 6) MCR: Match Control register – This register is used to control which all operations can be done when the value in MR matches the value in TC. Bits 0,1,2 are for MR0 , Bits 3,4,5 for MR1 and so on.. Heres a quick table which shows the usage: For MR0: ● Bit 0: Interrupt on MR0 i.e. trigger an interrupt when MR0 matches TC. Interrupts are enabled when set to 1 and disabled when set to 0. ● Bit 1: Reset on MR0. When set to 1 , TC will be reset when it matched MR0. Disabled when set to 0. ● Bit 2: Stop on MR0. When set to 1 , TC & PC will stop when MR0 matches TC. Similarly bits 3-5 , 6-8 , 9-11 are for MR1 , MR2 , MR3 respectively.
  • 13. Contd... 7) IR: Interrupt Register – It contains the interrupt flags for 4 match and 4 capture interrupts. Bit0 to bit3 are for MR0 to MR3 interrupts respectively. And similarly the next 4 for CR0-3 interrupts. when an interrupt is raised the corresponding bit in IR will be set to 1 and 0 otherwise. Writing a 1 to the corresponding bit location will reset the interrupt – which is used to acknowledge the completion of the corresponding ISR execution.
  • 14. Contd... 8) EMR: External Match Register – It provides both status and control of External Match Output Pins. First four bits are for EM0 to EM3. Next 8 bits are for EMC0 to EMC3 in pairs of 2. ● Bit 0 – EM0: External Match 0. When a match occurs between TC and MR0, depending on bits[5:4] i.e. EMC0 of this register, this bit can either toggle, go LOW, go HIGH, or do nothing. This bit is driven to MATx.0 where x=Timer number. ● Bits[5:4] – EMC0: External Match 0. The values in these bits select the functionality of EM0 as follows: ○ 0x0 – Do nothing ○ 0x1 – Clear the corresponding External Match output to 0 (MATx.m pin is LOW). ○ 0x2 – Set the corresponding External Match output to 1 (MATx.m pin is HIGH). ○ 0x3 – Toggle the corresponding External Match output. ● Similarly for Bits[7:6] – EMC1, Bits[9,8] – EMC2, Bits[11:10] – EMC3.
  • 15. LPC1768Timer Prescaler Calculations: The delay or time required for 1 clock cycle when PCLK = ‘X’ Mhz is given by : It is also the maximum resolution Timer block can proved at a given PCLK frequency of X Mhz. The general formula for Timer resolution at X Mhz PCLK and a given value for prescale (PR) is as given below:
  • 16. Contd... Hence, we get the Formula for Prescaler (PR) for required Timer resolution (TRES in Secs) at given PCLK(in Hz) frequency as: PR = (PCLKHz * TRES) – 1 PR = ((X * 106) * TRES) – 1 Note that here, the resolution is also the time delay required to increment TC by 1.
  • 17. Contd... Hence, Prescaler value for 1 micro-second resolution/ 1us time delay at 25 Mhz PCLK is, Prescale for 1 mS (milli-second) resolution at 25Mhz PCLK is, PR1ms = (25Mhz * 1ms) -1 = (25*106 * 10-3) -1 = 24999 The maximum resolution of all the timers is 10 nano-seconds when using PCLK = CCLK = 100Mhz and PR=0 which is as follows, TMAXRES = [1 / (100Mhz)] = 10ns PR1us = (25Mhz * 1uS) -1 = (25*106 * 10-6) -1 = 24