[LinuxPPS] GPIO PPS Generator

Drasko DRASKOVIC drasko.draskovic at gmail.com
Thu May 23 15:39:32 CEST 2013


On Thu, May 23, 2013 at 12:03 PM, Drasko DRASKOVIC
<drasko.draskovic at gmail.com> wrote:
> Hello Igor,
> think you very much for the code and the instructions. It has been
> extremely helpful, and I integrated
> your code in Ubuntu Precise 3.2 Linux kernel for my Pandaboard.
>
> Everything seems to work, and I can see PPS on the oscilloscope.
>
> My use case is not a standard PPS generator, though. I thought that I
> can use this mechanism to observe clock synchronicity (offest +
> jitter) between two Pandaboards.
>
> However, driver's hrtimer is started at the moment the driver is
> inserted into the kernel, and keeps pulsing every second. While this
> can be adequate for observing clock jitter between two boards, it is
> impossible to have offset observation, as initial offset will be
> unpredictable.
>
> What I am looking now is to have a pulse at exact sharp second in the
> sense : 1:00, 2:00, etc..., so, zero nanoseconds after round sharp
> second in local time.
>
> From what I can see in the code, we are always setting hrtimer to
> expire a little before and using getnstimeofday() to get our (local)
> time and conclude second. That would mean (I think) that if we can
> just start our hrtimer on exact round second, then after this it would
> continue pulsing on each second exactly.
>
> Do you have some suggestions how this can be done ?
>
> Thanks and best regards,
> Drasko

Hmmm... On the more carefull inspection of the code, it seems that
this driver does exectly what I want, i.e. that it "fires" on the
exact absolute second.

Igor, can you please confirm me that GPIO is toogled every round
second (i.e. 1:00, 2:00, i.e. when mS, uS and nS are zero), so that
it's phase is zero, and not with offset from this zeo-phase (i.e.
1s:25ms:52us, 2s:25ms:52us, etc...).


Can you also please explain why this minimal hardcoded 10ms
(ts.tv_nsec > 990 * NSEC_PER_MSEC) :
static inline ktime_t next_intr_time(struct pps_generator_gpio_data *data)
{
	struct timespec ts;

	getnstimeofday(&ts);
	return ktime_set(ts.tv_sec +
			((ts.tv_nsec > 990 * NSEC_PER_MSEC) ? 1 : 0),
			NSEC_PER_SEC - (send_delay +
			data->port_write_time + 3 * SAFETY_INTERVAL));
}

Thanks and best regards,
Drasko




More information about the discussions mailing list