Thursday, June 06, 2019

Sleepy Bee to MSP430 to STM32L031... Woeful complexity

I need a simple very, very low power MCU to form the basis of coin cell sized IoT sensor monitoring.
Here is what it needs to do:

  1. Control the Semtech SX1276 LoRa chip via SPI
  2. Talk to an accelerometer via I2C
  3. Spend a lot of time sleeping waiting for accelerometer events.
  4. Wake up, send a LoRa command and go back to sleep
  5. Wash, rinse, repeat.

(If you read this blog you'll know that C and pre-written Arduino or STM32Cube or whatever frameworks are not the answer for me.  I'm old and tired of learning your new (potentially half baked) frameworks. I've got spec sheets on the peripheral chips and know how to use them....)

So, I need to choose...

Sigh... the C8051 (Silabs SleepyBee) is just too low level. I've got enough 16 bit math and string manipulation to do that it simply doesn't make much sense to go this low.

MSP430 is long in the tooth. Sure, the specs are still there and the chips are available but they seem overpriced for what I need (basically 1KB RAM and maybe 32K Flash).  I'm not nickle-and-diming it, but it just feels wrong to pay $3-4 for such an old design.  I've got Forth Inc SwiftX MSP430 code and there is always Mecrisp too, so from a development perspective the MSP430 has what I need.  But, the chip availability is spotty and pricey...

What about ARM Cortex?  It's hard to beat the ARM Cortex these days. Size, power, diversity: It has that in spades.  I'm well versed with the STM32L496 and STM32L432 but those M4 beasts are overkill for my needs.  They are very complex chips.

So I stumble upon the STM32L031 and I am blown away by the datasheet specs. It's a Cortex M0+ with MSP430-like low power specs. Heck, it blows away most MSP430s. And is cheaper... given 8KB RAM and 32KB Flash.

A couple of years ago I ported Forth Inc's SwiftX ARM compiler to the STM32L432. It took a little effort, but it worked.  I think I used an STM32F411 as the basis for the port.  I'm not looking forward to porting to the STM32L031.  But wait, it looks like there is a Mecrisp-stellaris port for that chip. Hurrah!  But, wait again... its a bare port. No systick, no CMSIS mappings, etc.  Okay. I like bare metal stuff... but... I have this thing I want to build and I need something working soon.  Maybe I don't want to bite off the effort.  Let's see... there is already a systick interface in Mecrisp for another STM32 part, maybe I can start there.  But then I have to deal with sleep transitions.  On the MSP430 (and Sleepy Bee) it is dead easy. The STM32L  has always been a bear.  Is the L031 sleep code the same as the L432?  I hope so.. otherwise I have a lot of reading to do.

I download the L031 reference manual...  it's around 900 pages. Okay, I know I don't need to consume it all, but I'll need to do the laborious register bit hunt and the requisite ten thousand clocking options.

What am I doing here?  I need a simple low power microcontroller with an RTC sleep mode less than a couple of uA and run mode less than 5mA.  I want it with enough memory that I can get my stuff done.

To add to this dilemma, the STM32L072 (which should be very close to th STM32L031 I mentioned above) is now the darling of "module" embeds.  Well, "darling" may be overselling it, but there is a rather nice LoRa module I'm looking at that embeds this MCU. If (a big IF) I get the L031 working it should be a simple port to the L072.

But... I'm stuck on the overall complexity of the STM32L.  I've been there before (the L496), but I was paid to work with that chip for 9 months. Nine months living and breathing the nearly 2000 pages of reference manual.  Tweaking. Tuning.

Maybe MSP430 isn't dead to me after all. The MSP430F2274 (1KB RAM + 32KB Flash) is more than adequate.  I've got a SPI driver written. I've got a development environment. 
But at $6 (https://octopart.com/search?q=MSP430F2274)  it's insanely pricey.  The STM32L031 (which has more memory, features, smaller sizes and uses less power) is only around $2.50.

Honestly, I am not making millions of devices so a few dollars here and there doesn't really matter.

But I have to ask myself... is it worth the complexity?

Wednesday, May 15, 2019

Frustrated with Complexity

I've been doing a bit of ESP32 development at work (and some at home) and I've hit a wall.  When things fail, they fail bad. I can't say that I understand the xtensa toolchain (I do know that it takes several minutes to build an ESP32 binary on my laptop: FreeRTOS and my app).

I've been using LuaRTOS and am generally happy with it (a few crashes due to not quite well debugged libraries), but my problem is....

The more and more I use other people's code, the less I can say I know what is going on inside of my devices.  I am building (critical) house monitoring devices (including one that controls a pump via H-Bridge and PWM).  Not exactly real time constraints, but certainly 24/7 reliability. I need to know that this system can be trusted.

Okay, okay... so back to Forth.  Looking into replacing the ESP32 (w/ LuaRTOS) Copious Free Time project with a SleepyBee (w/ MyForth) and an ESP8266 (in AT command mode) for Wi-Fi connectivity.

Why?  Because I'm pedantic that way.  Close to the metal, baby!

Sunday, March 17, 2019

Alien Technology... of sorts...and a restart?

It's been a long time since I've blogged here.  I have no idea if anybody is still reading this, but I'll go ahead and say that I intend to start writing more blog entries in the coming weeks.

But, in the meantime, a bit of catch-up:

I've had a wonderful opportunity during 2017-2018 to work with GreenArrays and their wonderful GA144 chip, on an actual real work project.  There were lots of starts and stops, and not quite "full time", but we did deliver around 25 boards (and software) to the customer for "evaluation and proof-of-principle" goals.  They liked what they got (delivered last December), but... they don't know if they want to continue. 

I also got to do some more work with MyForth (Charley Shattuck's Arduino version) and have (for my own personal projects) pivoted back to the 8051 version (Charley & Bob Nash's work).
I ported MyForth to SiLab's (new) SleepyBee (EFM8SB2).  I'll write more about that later. Perhaps a lot more, since it is one of my Copious Free Time projects.

Taking a break from intense GA144 work (in PolyFORTH and arrayFORTH)  I am getting nostalgic for Forth block editors.  I'm an emacs die-hard, but there is something still very focused and useful in using a block editor (well, especially when it is integrated into your development environment as deeply as PolyFORTH is on the GA144).

I may dust off my GA144 EVB and do some toolsmithing or I may dive deeper into the MyForth tooling (hmmm... can I fit a block oriented dev environment on an EFM82B2?)  Recompilation is the challenge (as all of that is done in the PC under gforth).  I could use the gforth block editor but MyForth is not an incremental compiler....

Still... I expect to do more Forth in the next few months (if not at work, then on my Copious Free Time projects).  Stay tuned.