Code: Select all
# GPS pps interrupt on X1
import pyb
tick =0
us = 0
def callback(line):
global tick,us
us=pyb.micros()
tick=1
pin = pyb.Pin('X1')
pyb.ExtInt(pin, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_NONE, callback)
prev=0
while(1):
if (tick) :
t=us-prev
print (t, t-1000000, ' ppm')
tick = 0
prev = us
Using a long running simple python program to print pyb.millis() every 10 seconds to a host serial port that was running NTP, i measured pyboard frequency offset of 32 ppm.
Using the same NTP test harness but converting the RTC output to "milliseconds" (it has a 1/256 subsecond resolution), I measured the frequency offset of the 32khz crystal at 170 ppm. I think the 32khz pyboard crystal is spec'd at 50ppm. (The RTC hardware has the ability to prescale and calibrate the 32khz time soure, so the RTC frequency could be "adjusted".) Voltage, capacitance, age, and temperature can effect crystal frequency.