Subject: kern/10102: pps api clear/assert inverted
To: None <>
From: Wolfgang Rupprecht <>
List: netbsd-bugs
Date: 05/11/2000 23:55:12
>Number:         10102
>Category:       kern
>Synopsis:       pps api clear/assert inverted
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 11 23:56:00 PDT 2000
>Originator:     Wolfgang Rupprecht
>Release:        NetBSD-current May 9,  2000
W S Rupprecht Computer Consulting, Fremont CA

System: NetBSD 1.4Y NetBSD 1.4Y (WSRCC) #2: Tue May  9 17:00:21 PDT 2000 i386


	the PPS (pulse per second) api signals are reversed.  The
	PPS_CAPTUREASSERT event is monitored and flagged as a
	PPS_CAPTURECLEAR event and visa versa.


    run ntp from a known good source.  Let the clocks sync up for 
    10 minutes.  Ntp is none too speedy about this. 

    compile the following program.  hook up a PPS clock that 
    asserts the signal on the second and clears the signal 200 ms
    later.  (I'm using a motorola oncore M12 oem board).

    Notice that the assertion is at ~200ms after the second.
    Notice that the clear is at the even second.

    Shamelessly stolen from the RFC:

    #include <stdio.h>
    #include <unistd.h>
    #include <ctype.h>
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/stat.h>

    #include <sys/timepps.h>

     * Mogul, et al.                Informational                     [Page 22]
     * RFC 2783                  Pulse-Per-Second API                March 2000

    pps(int fd, char * PPSfilename)
	  pps_handle_t handle;
	  pps_params_t params;
	  pps_info_t infobuf;
	  int avail_mode;
	  struct timespec timeout;

	  time_pps_create(fd, &handle);

	   * Find out what features are supported

	  time_pps_getcap(handle, &avail_mode);
	  if ((avail_mode & PPS_CAPTUREASSERT) == 0) {
	      fprintf(stderr, "%s cannot CAPTUREASSERT\n", PPSfilename);
	  if ((avail_mode & PPS_OFFSETASSERT) == 0) {
	      fprintf(stderr, "%s cannot OFFSETASSERT\n", PPSfilename);

	   * Capture assert timestamps

	  time_pps_getparams(handle, &params);
	  params.assert_offset.tv_sec = 0;
	  params.assert_offset.tv_nsec = 0;
	  params.mode |= PPS_CAPTUREBOTH;
	  time_pps_setparams(handle, &params);

	  /* create a zero-valued timeout */
	  timeout.tv_sec = 0;
	  timeout.tv_nsec = 0;

	  /* loop, printing the most recent timestamp every second or so */
	  while (1) {
	      if (avail_mode & PPS_CANWAIT) {
		  time_pps_fetch(handle, PPS_TSFMT_TSPEC, &infobuf, NULL);
				  /* waits for the next event */
	      } else {
		  time_pps_fetch(handle, PPS_TSFMT_TSPEC, &infobuf,


	      printf("Assert timestamp: %d.%09d, sequence: %ld\n",

	      printf(" Clear timestamp: %d.%09d, sequence: %ld\n",

	I think the fix is as simple as throwing an inversion in where
	the DCD hardware line is tested.