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.

[ARM] ARM 32 bit Timer configuration

Status
Not open for further replies.

amsbhole07

Member level 1
Joined
Oct 28, 2010
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,535
I am using LPC1768 IC and external crystal 12 MHZ .
I am using Timer and i want to calculate exact time

timer.c file


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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
*****************************************************************************
** 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(uint8_t timer_num, uint32_t delayInMs)
{
  if ( timer_num == 0 )
  {
    LPC_TIM0->TCR = 0x02;       /* reset timer */
    LPC_TIM0->PR  = 0x00;       /* set prescaler to zero */
    LPC_TIM0->MR0 = delayInMs * (9000000 / 1000-1);
    LPC_TIM0->IR  = 0xff;       /* reset all interrrupts */
    LPC_TIM0->MCR = 0x04;       /* stop timer on match */
    LPC_TIM0->TCR = 0x01;       /* start timer */
  
    /* wait until delay time has elapsed */
    while (LPC_TIM0->TCR & 0x01);
  }
  else if ( timer_num == 1 )
  {
    LPC_TIM1->TCR = 0x02;       /* reset timer */
    LPC_TIM1->PR  = 0x00;       /* set prescaler to zero */
    LPC_TIM1->MR0 = delayInMs * (9000000 / 1000-1);
    LPC_TIM1->IR  = 0xff;       /* reset all interrrupts */
    LPC_TIM1->MCR = 0x04;       /* stop timer on match */
    LPC_TIM1->TCR = 0x01;       /* start timer */
  
    /* wait until delay time has elapsed */
    while (LPC_TIM1->TCR & 0x01);
  }
  return;
}
 
 
/******************************************************************************
** Function name:       Timer0_IRQHandler
**
** Descriptions:        Timer/Counter 0 interrupt handler
**
** parameters:          None
** Returned value:      None
** 
******************************************************************************/
void TIMER0_IRQHandler (void) 
{
 
///////////////////////////////////////
 
 
main file 
 
nt main (void)
{
    SystemInit();
    SystemClockUpdate();
    init_timer ( 0,71999999);
 
        
        enable_timer( 0 );
      
        
        
        LPC_TIM0->TCR = 1;
        NVIC_EnableIRQ(TIMER0_IRQn);
    
  while(1)
  {
 
  }
}


My query is how to calculate time interval .
what is the clk value
Time interval 71999999=1sec i got from oscilloscope .

please explain me how to calculate exact value
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top