Intro
Recently I've made progress on having an interpreted language running on the XMOS chip. I've found a small (but incomplete) lisp interpreter which fits in and runs with the limited memory of the chip. By using an interpreted language, programs can be run on the XMOS chip without the need for compilation. Unfortunately it doesn't contain a garbage collector (at this moment), meaning that an inevitable crash awaits a lot of the programs.
Examples
Primitives for ports and timers are added to allow various IO operations.
For example turning some leds on, on the development board:
This function returns the value set (in this case 15), allowing to chain multiple outputs:
Input is also supported using the following methods:
- simple read: (pin button)
- pin equal: (peq button 12)
- pin not equal: (pne button 15)
There is also support for timers. These evaluate to an integer value similar to the way they are used in XC. That way delays can easily be created by doing:
Using these timers the following demo was made. It is a function which is called recursively generating a small animation using the LEDs on the development board. The initial value (being 1) is multiplied by two on every function call, effectively shifting to the next led. The "mod 15", keeps everything in range.
Due to the lack of a garbage collector and the use of recursion, it will run out of memory after about 10-15 seconds.
Parallellism
At this moment there is no way to use the multithreading in the XMOS chip using the lisp interpreter.
0 comments:
Post a Comment