Saturday, September 26

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.


Filed under: ARM, Microcontrollers

No comments:

Post a Comment