You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Not sure I understand - what lengths should it be reporting back? What if you attach it to something like a PWM output that you know the frequency of?

    Also, is this the Espruino Board, or the Pico?

    Just tried this on the Pico:

    // short B3 and B4
    var d = 0;
    analogWrite(B3,0.5,{freq:1000}); 
    setWatch(function (e) {d=d*0.9+(e.time-e.lastTime)*0.1;}, "B4", { repeat:true, edge:'both' });
    

    and d is 0.00043812713 on one board and 0.00047730952 on the other. I think it's because the board is using the internal RC oscillator, which is supposed to be 40kHz but seems to be pretty inaccurate on the F401 chips.

    In fact you can check, because if you warm the chip up that number changes drastically.

    I think the only solution is to actually 'trim' the internal RC oscillator based on the external high speed crystal (which is relatively accurate) - I just haven't got around to adding the code for that yet.

About

Avatar for Gordon @Gordon started