source: rtems/c/src/lib/libbsp/m68k/mvme162/timer/timer.c @ 88d594a

4.104.114.84.95
Last change on this file since 88d594a was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*  Timer_init()
2 *
3 *  This routine initializes the Tick Timer 1 on the MVME162 board.
4 *
5 *  Input parameters:  NONE
6 *
7 *  Output parameters:  NONE
8 *
9 *  NOTE: This routine will not work if the optimizer is enabled
10 *        for some compilers.  The multiple writes
11 *        may be optimized away.
12 *
13 *        It is important that the timer start/stop overhead be
14 *        determined when porting or modifying this code.
15 *
16 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
17 *  On-Line Applications Research Corporation (OAR).
18 *  All rights assigned to U.S. Government, 1994.
19 *
20 *  This material may be reproduced by or for the U.S. Government pursuant
21 *  to the copyright license under the clause at DFARS 252.227-7013.  This
22 *  notice must appear in all copies of this file and its derivatives.
23 *
24 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
25 *  EISCAT Scientific Association. M.Savitski
26 *
27 *  This material is a part of the MVME162 Board Support Package
28 *  for the RTEMS executive. Its licensing policies are those of the
29 *  RTEMS above.
30 *
31 *  $Id$
32 */
33
34
35#include <rtems.h>
36#include <bsp.h>
37
38/* Periodic tick interval */
39#define TICK_INTERVAL                                   0x10000
40#define TIMER_INT_LEVEL                         6
41
42int Ttimer_val;
43rtems_boolean Timer_driver_Find_average_overhead;
44
45rtems_isr timerisr();
46
47void Timer_initialize()
48{
49  (void) set_vector( timerisr, (VECTOR_BASE >> 28) * 0x10 + 0x8, 0 );
50
51  Ttimer_val = 0;                                    /* clear timer ISR count */
52  lcsr->vector_base = 0x67800000;                /* set vb, enable interrupts */
53  lcsr->to_ctl = 0xE7;                /* prescaler to 1 MHz (see Appendix A1) */
54  lcsr->timer_cmp_1 = TICK_INTERVAL;
55  lcsr->timer_cnt_1 = 0;                                     /* clear counter */
56  lcsr->board_ctl |= 7;        /* increment, reset-on-compare, clear-ovfl-cnt */
57
58  lcsr->intr_level[0] |= TIMER_INT_LEVEL;                    /* set int level */
59  lcsr->intr_ena |= 0x01000000;              /* enable tick timer 1 interrupt */
60}
61
62#define AVG_OVERHEAD      6  /* It typically takes 3.0 microseconds */
63                             /* (6 countdowns) to start/stop the timer. */
64#define LEAST_VALID       10 /* Don't trust a value lower than this */
65
66int Read_timer()
67{
68  unsigned long                 total;
69
70  total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
71
72  if ( Timer_driver_Find_average_overhead == 1 )
73    return total;          /* in one-half microsecond units */
74
75  if ( total < LEAST_VALID )
76    return 0;            /* below timer resolution */
77
78  return (total-AVG_OVERHEAD);                  /* in musec units */
79}
80
81rtems_status_code Empty_function( void )
82{
83  return RTEMS_SUCCESSFUL;
84}
85
86void Set_find_average_overhead(
87  rtems_boolean find_flag
88)
89{
90  Timer_driver_Find_average_overhead = find_flag;
91}
Note: See TracBrowser for help on using the repository browser.