Professional Documents
Culture Documents
Timer - LPC
Timer - LPC
features
a timers Counters
La y channels per timer
To to 73
2s Co toCz
Total channels 16
a
3 take external Yp
C2
used for generating internal
timing functions
C Cannot generate external timing
and cannot take external
fun
Yp
a Timer
2
ways to use Kp't capture
D Outputmatch
Counter output
compare
INPUT CAPTURE
Used for finding time Intervals
Ton
Say q
yp I V
Ip capture can find time interval as
interval b w 2 rising edges
interval bw 2 falling edges
interval btw rising edge and the
falling edges Ton
Interval btw falling edge and the
rising edges TOFF
Channels in TIMER
can be used for ext up or entyp
tinchanwels
early
3
This case is Similar
for Timers Timer 2 Timea 3
Prey is
ThisPeon
IT used
In Sema Gatedelk
Igg is used to provide
on OFF control
Step2 Pinselect
veg Rinser is used to select the alternate
set functions
PINSELMeg LPC2378 1 PIN has 4 alternate functions Huttis 9 0
STM32 I PIN has 16 alternate functions
The pin select registers in LPC2378
There are 5 ports in LPC2378
POR o
PORT1 Ps3
ji
PORT2 Ps's
WYTV
Md PORT3 386
Ps
got
wed Each port has 32 bits
PORT4
each PINSEL veg is 32 bits But 2 bits are neg to
selectaltern fun of each Port So Single PINSEL reg can
handle 16 PINS
In 2bits
Default is Oo Gro
2 PINSEL
beg for each port
leg in total
D 10 PINSEL
00
Peck is scaled by 5 1
Op Peakscaled by 571
I Two sources
of CIA
pp PCLK
external signal thou CAP
Greene
this ext Signal is usedfor
the Ilp capture only and not
for counting process
only Pak is selected here It is done using CTCR beg
here functioning as a Counter i e counting eat pulses
X Ent
of the Polk ext clock
Ese for Ilp capture
em Cmo 00
x Ent
CISI CisO
It using the Pe you can have external trigger for CIA
capture
Cist Ciso
O O O
O 1
Ips
setup the Capture
Capture Reg for Timer 0123
veg TxCCR
plutempt
Because
only 2 channels are available
for this
ont
when it happens
the
an
for
then the difference b w 2 Captures can be
calculated
doEnable the
I forresetting the timer
timer
I
Bring value to zero
to check which of the yp has Caused the
Yp Capture
check from TxIR evey
Dubming
EYE
After acknowledging what has caused the
interrupt
read the capture registers
b
Uchannels Sofourcapture registers
ta to
though u registers are available
me for Yp Capture
ACRO
But only channelO's channels's Capture
evey is available for reading
Because
only channel0 channel I support
Input capture
OutputCompare Output match
1 4 32 bit match registers are available
for this
Optional interrupt generation on match
Stops the timer every time there is a match
resets the timer everytime there is match
2
up to a external signals are there associated
to match veg
4 types of narration you can set with
these external signals
Set low high Toggle Do nothing on match
aerated because of
EY
toggling
En En j
Timeros chano
chant
Timers chan O
Chand
exceptionally channel2 has
4 01ps
God
But in case Ilpcapture it
allows only 2of4ps
Programming for Op compare
for op compare there would be different pins
as compared to Yp Capture
Steps to program
ON the timer Program the pin select
Mdgftd
TxMRO TXMP3
Tx MCR É
gInterruptshould
raised
reset count
toggled
stop count when
match is detected
External match timer GXEMCR
register for
01 2 3
É
PI Select the eat Ur
Use the counter control evegister
Sas
for timers
Int P CLA 0 O O
Risingedge on O 1
as no Ga fully edge y o
crossing point bothlubing 0 I 1
Is to be counted falling edge
so use falling
edge here
Parts
To Reset and enable the timer
TIP R
122 timer preseaber Valve 11
To 12MHz
12 1MHz
Parts
Interrupt weep every I see
Imm freq is feed into the Counter
BEBER
Expert selected
Mimms
Using matchregister
Is
once
Laafterdone
I
see
and timer is
not reset
timer is stopped
after I see
Parts No op is req value stored in matchReg
Interrupt
Raised
tower stopped
Il in prescaber
un
G Peck
bag
Interrupt
Edocapture
capture to falling edge
deveninterrupt
coves
beset enable