Testing the 32kHz Watch Crystal

Posted on
  • According to http://www.espruino.com/Clocks the Watch Crystal will automatically be detected and used.
    I don't have an oscilloscope or a frequency counter.
    Is there any way to verify that the Espruino did indeed switch to the crystal like a function that prints the status?

  • Sure - there's nothing built-in, but it's what I use for testing:

    function getClockSource() {
      return ["NONE","LSE","LSI","HSE"][((peek32(0x40­021020)&768)>>8)];
    }
    getClockSource();
    

    It checks the actual registers in the chip to see what it's set to.

  • Thank you Gordon!

    I listed the meaning of the abbreviations below, for any one else who might also use the snippet:
    LSE = Low-speed external user clock
    LSI = Low-speed internal
    HSE = High-speed external user clock

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

Testing the 32kHz Watch Crystal

Posted by Avatar for AntiCat @AntiCat

Actions