2017 has been an eventful year so far, and for the first time in ages, I have been able to pause to take stock of these events. I write this from my quiet seaside dwelling in Hove – actually.
As of 16th Novemeber, I will no longer be a PAYE Employee – so it’s back to freelancing and picking up whatever work interests me and pays the bills.
This is a self imposed change – and it’s only the 3rd times in my 30 year career in electronic engineering that I have pulled the ripcord and bailed out of an otherwise steady job.
Whilst I will continue to pick up some part time contact work from my current employer, and wrap some things up in an orderly manner, the plan is to focus on my own project goals for at least two days a week.
In order to transit gently into this new way of working – I have decided to take a break, and so I am off to San Francisco on Thursday for 12 days.
During this trip, I will be reacquainting with old friends and colleagues, and attending the annual Forth Day – which is held on the Stanford University Campus – by the Silicon Valley Forth Interest Group.
As well as meeting up with some of the Forth group I will be doing a short presentation to introduce some of the things that I have worked on this year, plus some projects from other friends in the European Forth Community.
It’s a tall order, but somehow I have to condense some fairly broad subjects into a concise 18 minute presentation. – so in a rather tenuous manner – that’s why this blog begins with a picture of the Forth Bridge.
In this post I collect together some of the threads of various projects that I have started in the last 12 months – but for a variety of reasons have not yet been taken to conclusion.
Weaving these various threads together to make a stronger fabric – or canvas – on which I am going to paint a whole new strand of embedded technology. It’s taken all summer, the UK MegaTour with Toby Yu, the forced escape from my day job, and a bit of time to rationalise and coalesce some ideas – and these will form the basis of my presentation at Forth Day.
The Ideal Forth Microcontroller?
Earlier this year I began working with simple microcontrollers, in particular the MSP430 with non volatile ferro-electric memory or FRAM.
The MSP430 makes a good choice as a Forth machine as a result of its 16 bit architecture, it’s not volatile FRAM memory and the inclusion of an instruction that allows the $NEXT macro of the inner interpreter to be reduced to a single cycle instruction:
This indirect, autoincrement memory read instruction efficiently implements the $NEXT macro – and makes the direct threaded model for Forth superior to other threading models.
Key details of this direct threaded model and MSP430 eForth are now available in Dr. C.H Ting’s excellent book “Zen and the Forth Language” – now from Amazon, and I am indebted to Juergen Pintaske for making this publication available to the wider Forth Community. Dr Ting explains the inner working of the eForth implementation on the MSP430 in a most readable fashion and thus makes this key information available to a much wider audience.
The MSP430 makes an excellent choice for a Forth Computer using the direct threaded code model. It already has a 16 bit architecture, von Neuman unified memory space makes dealing with data and instructions somewhat simpler. It’s choice of low power, non volatile FRAM memory makes it virtually unique in the microcontroller market.
FRAM has a fast write cycle – about 100 times the speed of Flash, and with a life of 10E +14 cycles – it will not wear out anytime soon. EEprom is made redundant with FRAM, and the boundary between FRAM and SRAM can be moved – so that FRAM is used as RAM – allowing up to 8MHz operation.
The MSP430FR5994 with it’s massive 256K of FRAM is a new addition to the FRAM range of microcontrollers and at $3.76 (1000+) it is very affordable. Add to this an external SRAM memory and you have the makings of a powerful little machine. With volume production, it’s possible to have a complete Forth system for around $5 – including the USB programming adaptor.
Performance wise, it’s not in the ARM class, not even close, but at 16MHz full speed, it will run about 4 times the throughput of the Arduino R3.
One of it’s strengths is that it has been blessed with 3 communications ports – allowing a rich mix of asynchronous UART and synchronous SPI hardware to be added.
The MSP430 may be programmed with a variety of Forths, including Mecrisp, Amforth and 4E4th – the latter having a special port of Camel Forth available specifically for FRAM operation.
Recently I came across Fast Forth by Jean-Michel Thoorens – this is Direct Threaded Code, and has support for SD card. Programming is done making use of TeraTerm for file sending – at a full 921600 Baud. It was designed specifically for MSP430 with FRAM – needing just 8K bytes of FRAM.
Forth was designed as a complete, self contained tool-chain – including Editor, Compiler and Assembler – all the tools that you need to develop code, at your fingertips – present on the target chip. Now for the first time, with ChipStick we can have all of this on a tiny, manageable 20 pin DIL module – complete with it’s own USB programming interface.
ChipStick was my first venture into creating an MSP430 FRAM board in the form of a 20 pin DIL module that could replace the MSP430G2553 that comes in the Value Line Launchpad.
It features a detachable programming section, USB serial interface and 128K of SPI SRAM – which can be powered or backed up by supercapacitor or LiPo cell..
The early prototypes were created in March and sent out to various Forthers around the UK and Europe. As a result there are now three ports of Forths available for this tiny design.
Fast Forth – Jean Michel Thoorens
Mecrisp – Matthias Koch
Camel Forth for MSP430 FRAM – by Michael Kalus
Additional support came from Juergen Pintaske, Dirk Bruehl, Lars Brinkhoff and Mark Willis.
Now that the MSP430FR2433 is in volume production – this prototype – slightly enhanced can go into production.
This year I am relaunching my Nanode Design and Technology company with a range of new board designs.
The tiny MSP430FR2443 used on ChipStick is now commercially available – whereas in March it was only available in sample quantities. This means that I can push ahead with ChipStick and other related designs – including the even smaller Nanode 2016. This tiny module has the MSP430FR2433, which is $1.37 in production quantities, and the module can be fitted with external SPI RAM or FRAM – up to 128Kbytes. If you need a capable microcontroller in a small space – then this will do much more than the Arduino Nano.
Inspired by my colleagues in France and Germany with their ports of Forth to the MSP430 and my own efforts with the diminutive ChipStick running SIMPL in March and April, I was please to see in July the long awaited 256Kbyte FRAM MSP430 had become available and I had a couple shipped across from the US. This little $16 board has to be the preferred platform for anyone serious about experimenting with Forth and other stack based languages – on a mainstream commercially available microcontroller.
- 35 lines of GPIO brought out to Launchpad headers
- 2 User LEDs and 2 switches
- 256K bytes of FRAM!
- Low Energy Accelerator – a maths coprocessor
- microSD card
- Super Capacitor
- Very low energy with energy monitoring feature
- Programming interface with USB serial connection
Talking to small microcontrollers has traditionally been done with a serial terminal link, a text editor or an Integrated Design Environment (IDE).
I have been rummaging a new idea, which I hinted on earlier in the Summer – which I am now going to call “Forth Bridge”. It’s a way of connecting widely differing computer or processor systems using Forth like commands to convey information and instructions.
The idea arose from the work that James Bowman and I did on the FT812 EVITA graphics processor board back in January. Janes successfully applied the FT812 to his Gameduino II product – allowing a high performance handheld gaming device to be driven using an Arduino. This is possible because all of the hardware needed to support the graphics of the LCD is provided in the FT812 – and the Arduino need only supply a list of commands in order to generate the graphics display – and not the actual RGB pixel signals.
This offloading of the video to the video co-processor is something that has been done in home computers ad PCs since the early 1980s, but the FT812 does this in a $5 chip – effectively reducing the 65MHz bandwith video signal down to a list of video control commands sent over SPI at a few tens of kilobaud this puts it firmly within the grasp of any small microcontroller. I reworked James’s ideas so that the FT810 could drive a large LCD monitor at up to 1024×768 pixels – and thus my little EVITA board was born.
The next part of the jigsaw was to realise that all that Gameduino and EVITA are doing is connecting two computers together – one is a general purpose 8-bit microcontroller and the other is a machine dedicated to creating high bandwidth streams of pixels and rendering images. The 32 bit spi commands that are sent between them is a shorthand means of forcing the co-processor to execute it’s graphic generation primitives – so one computer is controlling another computer over a communications link. Whilst the ICs are generally only a few centimeters from each other – and SPI is the most appropriate comms interface, they could be in different rooms or continents, linked by RS232, ethernet or any other practical comms link.
The next piece of the puzzle was JM Thoorens Fast Forth – a direct threaded MSP430 FRAM Forth, which he supports with a simple serial UART connection to a PC. The only difference is that he is able to send Forth source from the PC text editor to the target at 6Mbaud using a low cost serial UART board that costs about a dollar from China (CP2104). Whilst the source code is sent generally from the PC to the target, there is no reason why debug and other interactive data cannot be sent in the reverse direction at a similar speed, and then be rendered by the PC, tablet or whatever to produce a highly interactive video display. If the PC emulates the command set of the FT810 – then the target can either talk to a real on board FT810 or a PC – without changing the command set.
This then allows a whole host of interactive devices to be created from low cost microcontrollers fitted with low cost LCDs. You may recall that I mentioned in the Summer that a 7″ touch screen is now about $30.
Commands, communications, computers talking to each other? This sounds like a job for Forth. An intelligent Forth, that runs across all platforms, that if I were naming it – I’d probably call it iForth. So I googled it, and I see that it already exists – and is well into its 21st year!
That’s good – it makes the PC end so much simpler if there’s already a tool that can do all the heavy lifting. So we can host a GUI, and IDE and whatever cross compilers that are needed on any platform from a smart phone, tablet, laptop or PC. And just reading that last sentence – the word GUIDE leaps out of the text. A graphical user interactive development environment…….
We can also start to explore some of the other ideas, I hinted on in the summer. New ways to write code and display the inner workings of the processor we are targeting. Now that the target can send a lot more than a hex-dump or source code listing to the PC, we can start to look at new ways of understanding the way the code sits and runs on the target. We can interact with the processor in whole new ways to better grasp the application and see much further into the logic processes. And in this respect – it makes an excellent platform for education. More on this in a later post
So we have a PC or tablet platform running an iForth toolset, and a useful “off the shelf” educational target in the form of the latest MSP430 FRAM launchpad running Fast Forth.The third thing in this unholy alliance, is to extend these principles to custom Forth processors – and this is the main thrust of my involvement this year.
Forth and FPGAs
myStorm is a low cost FPGA and ARM dev board – aimed at makers and hobbyists. It consists of a Lattice ICE40HX4K FPGA and an STM32L433 microcontroller. There is also a 256K x16 SRAM closely coupled to the FPGA and a USB programming interface.
James Bowman has already ported his J1a Forth processor to the myStorm board and Matthias Koch has ported he Mecrisp Forth to the STM32 ARM M4 Cortex microcontroller. Now we have two very different processors, both running Forth – and coupled with a high bandwidth link. This is where things start to become exciting.
Whilst the ARM M4 is a very capable processor in its own right, it’s main role is to provide a standard set of peripherals, interfaces and 5MSPs ADC and make these available to the FPGA. The user can then focus on the design of the FPGA, knowing that the peripherals are standard – and won’t need to be synthesised within the FPGA. The user can then develop his ideas in the knowledge that all the support hardware is taken care of.
Since the early 1960s, computer engineers have been connecting widely different computing systems together – sometimes this might be several machines on a network, but initially it started with just a complementary pair of machines connected to achieve a specific goal.