Changeset e8918ec in rtems
- Timestamp:
- 12/13/99 22:12:03 (24 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- f09ac268
- Parents:
- c629812
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/gen68360/clock/ckinit.c
rc629812 re8918ec 54 54 55 55 /* 56 * RTEMS and hardware have different notions of clock rate. 57 */ 58 static unsigned long rtems_nsec_per_tick; 59 static unsigned long pit_nsec_per_tick; 60 61 /* 56 62 * Periodic interval timer interrupt handler 57 63 */ … … 60 66 Clock_isr (rtems_vector_number vector) 61 67 { 62 /* 63 * Perform a dummy read of DPRAM. 64 * This works around a bug in Rev. B of the 68360 65 */ 66 m360.dpram0[0]; 68 static unsigned long nsec; 67 69 68 70 /* 69 * Feed the watchdog 70 * Application code can override this by 71 * setting M360DefaultWatchdogFeeder to zero. 71 * See if it's really time for a `tick' 72 72 */ 73 if (M360DefaultWatchdogFeeder) { 74 m360.swsr = 0x55; 75 m360.swsr = 0xAA; 73 nsec += pit_nsec_per_tick; 74 if (nsec >= rtems_nsec_per_tick) { 75 nsec -= rtems_nsec_per_tick; 76 77 /* 78 * Perform a dummy read of DPRAM. 79 * This works around a bug in Rev. B of the 68360 80 */ 81 m360.dpram0[0]; 82 83 /* 84 * Feed the watchdog 85 * Application code can override this by 86 * setting M360DefaultWatchdogFeeder to zero. 87 */ 88 if (M360DefaultWatchdogFeeder) { 89 m360.swsr = 0x55; 90 m360.swsr = 0xAA; 91 } 92 93 /* 94 * Announce the clock tick 95 */ 96 Clock_driver_ticks++; 97 rtems_clock_tick(); 76 98 } 77 78 /*79 * Announce the clock tick80 */81 Clock_driver_ticks++;82 rtems_clock_tick();83 99 } 84 100 … … 99 115 Clock_driver_ticks = 0; 100 116 if ( BSP_Configuration.ticks_per_timeslice ) { 101 int pitr;102 103 117 /* 104 118 * Choose periodic interval timer register value 119 * The rate at which the periodic interval timer 120 * can generate interrupts is almost certainly not 121 * the same as desired by the BSP configuration. 122 * Handle the difference by choosing the largest PIT 123 * interval which is less than or equal to the RTEMS 124 * interval and skipping some hardware interrupts. 125 * To reduce the jitter in the calls to RTEMS the 126 * hardware interrupt interval is never less than 127 * the maximum non-prescaled value from the PIT. 128 * 105 129 * For a 25 MHz external clock the basic clock rate is 106 130 * 40 nsec * 128 * 4 = 20.48 usec/tick 107 131 */ 108 pitr = ((BSP_Configuration.microseconds_per_tick * 100) + 1023) / 2048; 109 if (pitr >= 256) { 110 pitr = (pitr + 255) / 512; 111 if (pitr >= 256) 112 pitr = 255; 113 else if (pitr == 0) 114 pitr = 1; 115 pitr |= 0x100; 132 int divisor; 133 extern int m360_clock_rate; /* This should be somewhere in a config file */ 134 unsigned long nsec_per_chip_tick = 1000000000 / m360_clock_rate; 135 unsigned long nsec_per_pit_tick = 512 * nsec_per_chip_tick; 136 137 rtems_nsec_per_tick = BSP_Configuration.microseconds_per_tick * 1000; 138 divisor = rtems_nsec_per_tick / nsec_per_pit_tick; 139 if (divisor >= 256) { 140 divisor = 255; 116 141 } 117 else if ( pitr == 0) {118 pitr = 1;142 else if (divisor == 0) { 143 divisor = 1; 119 144 } 145 pit_nsec_per_tick = nsec_per_pit_tick * divisor; 120 146 m360.pitr &= ~0x1FF; 121 147 m360.picr = (CLOCK_IRQ_LEVEL << 8) | CLOCK_VECTOR; 122 148 set_vector (clock_isr, CLOCK_VECTOR, 1); 123 m360.pitr |= pitr;149 m360.pitr |= divisor; 124 150 atexit (Clock_exit); 125 151 }
Note: See TracChangeset
for help on using the changeset viewer.