This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Easy way to bring LFCLK out on a GPIO?

Hello,

We're interested in measuring the precision of our external crystal, but don't have the equipment to measure off the crystal directly without affecting capacitive loading.

Some microcontrollers have the ability to drive the clock out a GPIO pin, but I haven't seen anything mentioned for the nRF51822.

I've been able to use the RTC tick event to trigger a GPIOTE task to toggle a pin, but this ends up dividing our clock by 2 and possibly introducing further jitter.

I'd like to know if there's a direct way to bring out LFCLK on a GPIO, and if there isn't, whether using the RTC tick event though PPI and GPIOTE will introduce jitter (and how much).

Thanks everybody!

  • I think what you're looking for is similar to the CLKOUT on common microcontrollers where the main or auxiliary clock is either sent unaltered to a pin or through a PLL to divide by a 2s divider? AFAIK, you can't do this on the nRF51.

    In one of our applications we divided the system clock using GPIOTE/PPI (16MHz > 1Mhz) and get a very decent square wave out of it at virtually exactly the predicted frequency according to our 'scope. Not much jitter at all.

    But, let's go back to basics here: why are you interested in the precision of your external crystal? What are you trying to prove or disprove?

    -m

  • We're trying to measure the precision of our external crystal oscillator as laid out on actual PCBs so we can intelligently set the connection interval window for power savings. While we could trust the crystal manufacturer's datasheet completely, we expect some deviation from ideal conditions and want to know how much we might see. We'll also need to account for aging. We've used a fudge-factor up until now in development (2x rated ppm + a little extra), but we're optimizing for low power and every microampere counts.

    Yes, you're right, we're looking for something like CLKOUT for the LFCLK. I wanted to know if my use of the RTC, PPI and GPIOTE to simulate the behavior of a CLKOUT would represent the crystal with high fidelity, or if the peripherals would introduce noise into the measurement.

    We may end up renting equipment to probe the crystal or outsourcing the measurement.

  • I guess you can expect very little jitter in actual frequency and your primary focus is on the deviation of a particular piece or quartz plus the influence of the capacitive loading.

    For that, you could do best by actually counting the cycles by a test firmware over externally provided exact (do you have atomic clock? ;-)) timebase (or the other way around) - your interrupt latency would be mostly constant and quite irrelevant when done e.g. over 1M cycles (if you can afford to let the piece spend 30s on a test rig)

Related