0% found this document useful (0 votes)
7 views13 pages

Blinking of LED Using Timer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Blinking of LED Using Timer

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Blinking of LED using timer

Experiment No.3
Blinking of LED using timer
Crystal Input
Clock in
LPC2148
CPU
Oscillator PLL

GPIO
Timer
VPB DIV UART
ADC
DAC
I2C
SPI
Crystal Input Clock in
LPC2148
Oscillator PLL CPU

Prescalar 1KH Timer Counter


VPB DIV Register
(PR)
z (TC)
TCl
k

PR = (Frequency of Pclk) / (Frequency of Tck)


CTCR : Count Control
•register
Used to select Timer/Counter Mode.
• For Timing purpose we use this in Timer Mode.
• When the value of the CTCR is set to 0×0 Timer Mode
is selected.
Prescalar Register
(PR) • PR : Prescale Register (32 bit) – Divides the Input
frequency to a desired value

PR
Pcl Tcl
k k

PR = (Frequency of Pclk) / (Frequency of Tck)


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.
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.

Total Counts = 429,49,67,296


Setting up & configuring
Timers
• Set appropriate value in TxCTCR (Count Control Register  Set as
Timer )
• Define the Prescale value in TxPR (Prescale Register)
• Reset Timer – Which resets PR and TC
• Set TxTCR to 0×01 to Enable the Timer when required (Timer Control
Register)
• Reset TxTCR to 0×00 to Disable the Timer when required (Timer
Control Register)
Initialize
Timer
T0CTCR = 0x00;
T0PR = PRESCALE-1;
T0TCR = 0x02;
//Reset Timer
For 1 ms
Tick
Tclk =
Pclk = 60
PR 1KHz TC
MHz

PR+1 =
60MHz/1KHz
= 60,000
PR = 59999
For 1 us
Tick
Tclk =
Pclk = 60 1MHz
PR
MHz
TC0

PR+1 =
60MHz/1MHz
= 60
PR = 59
Blinking of LED using timer -
Program

You might also like