يحاول ذهب - حر
Learn Lisp Programming Using MCUs - Part 2: Extending µLisp with Custom Functions
February 2025
|Circuit Cellar
In the second installment of this series, Raul delves into the world of µLisp and shows how to extend capabilities by adding custom functions such as "pulsein" and "servo-create", enabling developers to interface with ultrasonic sensors and control servomotors. In Part 1, Raul presented µLisp concepts and syntax, and extensions specific to MCUs.
μLisp is a dialect of the Lisp programming language. It is tailored to microcontrollers having limited amounts of RAM, and can be run on various platforms—from the Arduino Uno based on the ATmega328, up to the Teensy 4.0/4.1 [1]. To follow the topics discussed here, you need to be acquainted with the Arduino platform and any programming language from the Lisp family. Please see Part 1 of this article series (“Crash Course Offers Insight into Pioneering Language,” Circuit Cellar 411, October, 2024) for a brief introduction to Lisp programming and the µLisp dialect [2].
With µLisp, it is possible to add your own extension functions, such that they appear as built into the language after re-compiling and flashing the µLisp interpreter to your Arduino board. There’s an excellent tutorial on how to do this on the µLisp website [3]. I will build on that tutorial to discuss how to add custom functions. For the examples presented here, I will continue to use Seeed Studio’s Wio Terminal MCU development board; but the information discussed also can be applied to other µLisp-supported Arduino boards.
EXTENDING µLISP
In general, any function not supported by default in µLisp can possibly be added as an extension to the language—for instance, hardware access functions for servomotor control. Let’s explore a simple example to help us understand how the language extension system works.
Listing 1 shows the Arduino C code for adding the pulsein extension to µLisp, which is not available by default. This extension will make it possible to measure digital pulse widths. Five sections of the listing show the µLisp extensions structure. Like the core µLisp interpreter, extensions are also written in Arduino C language. So, any extensions to the interpreter imply basically writing C code. That makes adding them straightforward, using the Arduino C language built-in functions and external libraries.
هذه القصة من طبعة February 2025 من Circuit Cellar.
اشترك في Magzter GOLD للوصول إلى آلاف القصص المتميزة المنسقة، وأكثر من 9000 مجلة وصحيفة.
هل أنت مشترك بالفعل؟ تسجيل الدخول
المزيد من القصص من Circuit Cellar
Circuit Cellar
A GPS-Disciplined Frequency Counter using the PSoC 5LP
In this month's column, Brian tasks one of his mixed-signal favorite MCUs, the Infineon PSoC 5LP, to build a frequency/ period counter using a GPS satellite module to discipline the project's time base.
16 mins
November 2025
Circuit Cellar
Designing Analog Electronics
Part 1: Error and Uncertainty
23 mins
November 2025
Circuit Cellar
Samtec Launches 800-Position AcceleRate HP High-Performance Array Connectors
Samtec, Inc., a global leader in high-performance interconnect solutions and a service leader in the industry, announces the expansion of its AcceleRate HP product line with the release of 800-position APM6 and APF6 high-performance array connectors available in a low-profile 5mm stack height.
1 min
November 2025
Circuit Cellar
CIA for SBCs (and More)
Securing Embedded Systems from Evolving Threats
14 mins
November 2025
Circuit Cellar
The Future of Embedded Systems and AI: AI in Embedded Systems
Cybersecurity Challenges and Opportunities in a Smarter World
4 mins
November 2025
Circuit Cellar
An ESP32 Dashboard
Monitoring How a Popular Microcontroller Uses Resources
11 mins
November 2025
Circuit Cellar
Vishay Intertechnology Power Metal Strip Resistor Delivers Power to 5 W in Compact 1206 Case Size
Vishay Intertechnology, Inc. introduced a new surfacemount Power Metal Strip current sense resistor that combines a high power rating up to 5W, TCR down to ± 75ppm/°C, and extremely low resistance values down to 0.3mΩ in the compact 1206 case size.
2 mins
November 2025
Circuit Cellar
ROHM Develops New Smart Switches Optimized for Zonal Controllers
ROHM Semiconductor announced the release of six new high-side smart switches (IPDs: Intelligent Power Devices) featuring highly accurate current sensing and low ON resistances ranging from 9mΩ to 180mΩ.
1 min
November 2025
Circuit Cellar
Bourns Expands Semi-Shielded Power Inductor Portfolio with New Series Featuring Higher Maximum Inductance Values
Bourns, Inc., a leading manufacturer and supplier of electronic components for power, protection, and sensing solutions, announced the expansion of its semi-shielded power inductors.
1 min
November 2025
Circuit Cellar
STMicroelectronics' New Automotive Linear Voltage Regulator Preserves Battery Energy in Challenging Conditions
The TL99VR03 300mA low-dropout (LDO) regulator provides resilient and efficient power, with a wide input-voltage range and very low quiescent current consumption, only 3.5µA at no load. The IC has an enable pin for turning the regulator off, which reduces the idle current to 800nA, and integrates soft-start circuitry to limit current during power-up and fault recovery.
1 min
November 2025
Listen
Translate
Change font size
