Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

delay calculation using timer in lpc2129

Status
Not open for further replies.

senthil_99

Newbie level 6
Joined
Aug 8, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,343
could any one say , how calculate 10 milli sec delay using timer in lpc2129
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
A read the datasheer recommendation doesn't really reply the question.

Tahmid, have you used any LPC2xxx microcontroller (ARM7TDMI)?
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
A read the datasheer recommendation doesn't really reply the question.

Tahmid, have you used any LPC2xxx microcontroller (ARM7TDMI)?
I haven't. Google search took me to the Keil forums on previous timer-related threads, where the members kept on mentioning about going through the user manual.
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
Unless you are familiar with the hardware that the user refers to I don't see how you can help.

@senthil_99
I'm attaching two files from the LPc23xx code bundle , they include a delay_ms function you can study and use.
The timers in all 21xx, 23xx, 24xx are the same so using the code shouldn't be a problem.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*****************************************************************************
** Function name:       delayMs
**
** Descriptions:        Start the timer delay in milo seconds
**                      until elapsed
**
** parameters:          timer number, Delay value in milo second             
**                      
** Returned value:      None
** 
*****************************************************************************/
void delayMs(BYTE timer_num, DWORD delayInMs)
{
  if ( timer_num == 0 )
  {
    /*
    * setup timer #0 for delay
    */
    T0TCR = 0x02;       /* reset timer */
    T0PR  = 0x00;       /* set prescaler to zero */
    T0MR0 = delayInMs * (Fpclk / 1000-1);
    T0IR  = 0xff;       /* reset all interrrupts */
    T0MCR = 0x04;       /* stop timer on match */
    T0TCR = 0x01;       /* start timer */
  
    /* wait until delay time has elapsed */
    while (T0TCR & 0x01);
  }
  else if ( timer_num == 1 )
  {
    /*
    * setup timer #1 for delay
    */
    T1TCR = 0x02;       /* reset timer */
    T1PR  = 0x00;       /* set prescaler to zero */
    T1MR0 = delayInMs * (Fpclk / 1000-1);
    T1IR  = 0xff;       /* reset all interrrupts */
    T1MCR = 0x04;       /* stop timer on match */
    T1TCR = 0x01;       /* start timer */
  
    /* wait until delay time has elapsed */
    while (T1TCR & 0x01);
  }
  return;



Fpclk is the peripheral clock frequency.
 

Attachments


Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top