Real time clock on Pico (rev 1.4)

Posted on
  • Hi

    I'm building a Programmable Timer Switch (Synchronizing time with DCF77 - from time to time) on espruino Pico so I need a quite accurate clock.
    Do I need a external RTC (like DS1307 or DS3231) or internal crystal is accurate enough for a clock?
    I'm quite confused because here we've got: espruino.com/Pico+Clock

    While the Pico has an RTC built in, by default it doesn't have an accurate watch crystal and so uses its internal oscillator which isn't that accurate. It won't keep proper time over a month

    but, on the other hand, there is a clock frequency crystal in schematic - which should generate very accurate time

    Thanks for your help

  • Ahh, yeah - it's in the schematic, and there are pads for it (right at the end of the board), but it isn't fitted.

    You can fit one if you want, and it'll be automatically detected and used. In reality the capacitor values should be under 4pF, and are so small they can actually be left off without any real problems. You just need an ABS06-107 crystal. The 107 bit is important though.

    The Espruino WiFi does have the crystal installed, so if you wanted then that is another option as well.

  • Thanks @Gordon

    am I getting it right?

    btw, is there a way to check if it's successfully detected and used?


    1 Attachment

    • IMG_0820.jpg
  • That's right, yes! Definitely try without the capacitors first, as they can be a pain to solder :) If you have a hot air gun then the crystal should be pretty easy to add though.

    To test, just run the following magic code more than 5 seconds after startup:

    (function() {
      console.log("LSEON",peek32(1073887344)&1­);
      console.log("LSERDY",peek32(1073887344)&­2);
      console.log("LSION",peek32(1073887348)&1­);
      console.log("LSIRDY",peek32(1073887348)&­2);
      console.log(["NONE","LSE","LSI","HSE"][(­(peek32(1073887344)&768)>>8)]);
      console.log("RTCEN",!!peek32(1073887344)­&32768);
      // RTC subsecond
      console.log("Subsecond:", peek32(0x40002828));
    })();
    

    It'll say LSI without a crystal (low speed internal), and LSE with one (low speed external)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Real time clock on Pico (rev 1.4)

Posted by Avatar for ancienthero @ancienthero

Actions