Low-level access to STM32 peripherals using JavaScript

Posted on
  • I posted a new tutorial up here:

    http://www.espruino.com/STM32+Peripherals

    It's a bit heavy, but it shows you how you'd go through the process of looking at the chip's reference manual, decoding it and turning it into JavaScript that can set the hardware up in interesting ways.

    At the end of the tutorial you end up with:

    • A hardware cycle counter
    • Input Capture - the ability to store the counter's value in hardware when an input changes
    • Capacitive touch sensor using STM32 hardware
  • Very nice :) The power of peek and poke.

  • ACCESSING THE TIMER

    ...

    So the counter is actually counting up.

    COUNTING EDGES

    So that was interesting, but not really useful. What if we wanted to actually count the amount of times a pin changed state?

    Why would you call this ...not really useful? - Is there a better way do make a rpm or frequency counter/display? ...using a read/reset the count, setInterval() or setTimeout() of a particular value, read the count, do the math, show the rpms/frequency?

    CAPACITIVE TOUCH SENSOR

    Input capture really shines when you use it alongside another timer channel on the same timer.

    Would that qualify for a component to build a Theremin-like instrument? ...recalling some discussion/post when @Gordon asked for PICO applications and then made the game for moving a ring around a crazy bent wire without touching?

  • but not really useful

    Well, I was referring to accessing the value of the counter that's just counting up at a fixed rate - obviously it's useful when it's counting an external input - but that's what the COUNTING EDGES bit is for :)

    Touch - Would that qualify for a component to build a Theremin-like instrument?

    Yes, almost certainly. With a bit of fiddling I'm sure you could get it a bit more sensitive and could use it to control pitch/volume or something...

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

Low-level access to STM32 peripherals using JavaScript

Posted by Avatar for Gordon @Gordon

Actions