home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vxworks
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!marcu
- From: marcu@leland.Stanford.EDU (Marc Albert Ullman)
- Subject: Re: MVME167 and RealTime Clock
- Message-ID: <1992Aug14.024626.21811@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: DSG, Stanford University, CA 94305, USA
- References: <1992Aug14.013252.7600@chiton.ucsd.edu>
- Date: Fri, 14 Aug 92 02:46:26 GMT
- Lines: 36
-
- In article <1992Aug14.013252.7600@chiton.ucsd.edu> cdl@chiton.ucsd.edu (Carl Lowenstein) writes:
- >I just spent the better part of a day wondering why elapsed time as
- >measured by counting clock ticks was not tracking well with time of day
- >as determined by reading the real-time clock chip.
- >
- >Deep down in the inside of the PCC2 hardware is a prescale divider
- >that divides the CPU clock rate (25 MHz) to make the timer clock.
- >The MVME167 Programmers Manual points out that the byte that controls
- >the prescaler should be set to (256 - BCLK), or 0xe7 for 25 MHz.
- >I found both by peeking at the hardware register and by examining
- >the code in vw/config/mv167/sysLib.c that the number in use was 0xe6.
- >The one's complement of 25, rather than the two's complement.
- >
- > *PCC2_PRESCALE = ~BCLK; /* one's complement, wrong */
- >
- > *PCC2_PRESCALE = -BCLK; /* two's complement, right */
- >
- >What a difference between the little straight line and the little wiggly one!
-
- While I agree with your general problem assessment--indeed the library
- code is wrong--your fix is not quite correct. It is the Prescaler Clock
- Adjust Register that is being incorrectly initialized. It is not clear
- why the driver even bothers writing to the Prescaler Count Register since
- the documentation says it is a read-only register (although the register
- map says otherwise). Thus I believe the correct fix is to change:
-
- *PCC2_PRESCALE = ~BCLK;
- *PCC2_PRESCALE_CLK_ADJ = ~BCLK;
- to:
- *PCC2_PRESCALE_CLK_ADJ = 256 - BCLK;
-
- Yes, I realize that for a char register the 256 is unnecessary but it
- makes it clearer that one read the documentation.
-
- --Marc Ullman
- Stanford University
-