STM32 JavaScript Peeks And Pokes

A lot of people find scripting languages very productive and we’ve seen quite a few chips now supporting what you normally think of as a scripting language. These high-level abstraction languages are great, until they aren’t. When you need to go under the abstraction and do something complex or you need every cycle of performance, you might have to break your normal tools.

The Espruino is an ARM processor (an STM32) that has JavaScript on board. However, [Gordon Williams] shows how you can use peeks and pokes to access the hardware directly when the need arises. The names derive from another popular abstraction’s escape hatch. The old BASIC languages allowed direct memory access using keywords peek and poke. [Gordon] shows some examples of accessing the timer for PWM, and even looks at the STM32 reference manual to show how he knew where to peek and poke to begin with.

We dislike abstraction layers you can’t break. If C couldn’t embed or call assembly, it wouldn’t be as powerful as it is, for example. Giving advanced users a way to break your abstraction makes it more useful in more situations.

You might enjoy an earlier post if you want to learn more about the Espruino (and check out the video below for a JavaScript/Espruino-driven robot). Another popular embedded scripting language is Lua–we’ve done many posts on the ESP8266 running it.

8 thoughts on “STM32 JavaScript Peeks And Pokes

  1. If you really need something not implemented in javascript, you can write it in assembler or C and recompile your espruino code. There are tutorials on how to do this. Peek and poke are only good if you need to do something non-standard and only in few places in code.

  2. Really cool article regarding the STM32. Espruino.

    This is a great stepping stone into making a ST Arm procs more easy to learn/handle.
    Yes, there are sacrifices to overhead using a weakly typed dynamic language. But this is nice intro into making hacking more accessible to a non EE crowd.

    Many of us are fixated on squeezing out the most optimized firmware and baremetal execution of their project.

    Bearing in mind the fact that with an interpreted language such as javascript OR micro-python you don’t have to reflash/reprogram if you run into bug AND you can run commands on the fly is nice.

    That said another low-end board @ $35 is the hxxp:/tessel.io they have a Tessel v2 (shipping Nov 2015) now. With a solid foundation of modules you can customize on board and with various shield. It’s Node.js based so it’s friendlier to folks that what to invent and don’t want to deal with serving a messed up client.

    *cheers* Here is to wishing Van Rossum had gone to the Mozilla foundation instead of Google.

    1. p.s. I am not fond of javascript, don’t own any javascript centric tech (-minus the browsers we use). Just wanted to point out it’s easy to use. I would not mind a buying a few new Espruino’s with the new STM32F746/756 that can switch between java and baremetal flash.

      Non-registered. All names should belong to [Gorgon] – Post should indicate time date stamp and validity regarding anti-squatting.

      caffuino
      ritaluino
      adderuino
      methamphuino
      nzt-uino

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.