Incorrect PIT value inititalization?
Joel Sherrill <joel@OARcorp.com>
joel.sherrill at OARcorp.com
Tue Oct 19 17:06:20 UTC 2004
Leon Pollak wrote:
> 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?
Hopefully someone will confirm this solution. When you get a patch,
please file it as a PR.
> Thanks
> Leon Pollak
>
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list