Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

delay calculation using timer in lpc2129

Status
Not open for further replies.
A read the datasheer recommendation doesn't really reply the question.

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

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.
 

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

  • timer.c.zip
    2.1 KB · Views: 76

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top