Incorrect PIT value inititalization?
Leon Pollak
leonp at plris.com
Tue Oct 19 16:10:23 UTC 2004
Hello, all.
We have some problem with the PIT initialization code for MPC860. As
it
resides in the common directory, we think that it is worth asking the
question here.
Our board has the 5MHz XTAL clock. The file
/opt/rtems/rtems-src/c/src/lib/libcpu/powerpc/mpc8xx/clock/clock.c:72
in function ClockOn the code that initializes the PIT value (see below)
seems to be incorrect in case of a slower XTAL (not 50MHz as mbx860 has),
yielding float values for clicks_per_usec.
For example a 5MHz XTAL divided by 4 produces a 1.25MHz frequency, which
means that clicks_per_usec = 1.25. When it is assigned to an unsigned32
member it is truncated to 1, and the resulting value is only a rough
estimate of the value actually desired.
Original code:
pit_value = (rtems_configuration_get_microseconds_per_tick() *
rtems_cpu_configuration_get_clicks_per_usec()) - 1 ;
We suggest the following modification:
/* PIRTCLCK is XTAL / 4. XTAL is computed from the clock speed and
PLPRCR. */
unsigned long pitrtclk = (Cpu_table.clock_speed / ((m8xx.plprcr >> 20) +
1)) >> 2;
pit_value = pitrtclk / 1000 * rtems_configuration_get_milliseconds_per_tick()
- 1;
Do MPC8xx gurus agree?
Thanks
Leon Pollak
More information about the users
mailing list