EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: funkathustra on July 30, 2017, 06:19:30 pm

Title: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 06:19:30 pm
Hey everyone! I'm reviewing $1 (@ 100 QTY) general-purpose 8/16/32-bit MCUs from a wide range of vendors, and I'm looking for leads on parts. The review will include quantitative comparisons between feature sets, benchmarking (via a 16-bit biquad filter test measuring kSPS and nJ/sample), power analysis, plus more qualitative stuff (development environment, SDKs, compiler choices, development/debugging experience, etc).

I started with a pretty humble list, then hit up AVRFreaks, where several members recommended some interesting parts. Thought I'd try my luck over here, too!

The only rule is that the part has to be $1 or less @ 100 units from reputable sources (something on Octopart, or direct from the manufacturer). If a part isn't available from U.S. based distributors, I'm cool with eBay / Ali Express / Taobao links at that point. Please no Newark close-out specials on NRND parts.

So far, the big list is:
Atmel ATTiny1616
Atmel ATSAMD10
Cypress PSoC 4000S
Freescale (NXP) MKE04
Freescale (NXP) MKL03
Infineon XMC1100
Microchip PIC16LF18855
Microchip PIC24F04KL100
Microchip PIC32MM
Nuvoton N76E003
Nuvoton M052LDN
NXP LPC811
Renesas RL78/G12
Silicon Labs EFM8LB11
ST STM8S005K6
ST STM32F030
STC IAP15W4K61S4
Texas Instruments MSP430FR2111

Anything I'm missing? Thanks!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on July 30, 2017, 06:40:33 pm
I don't see the value in such a test. At 100 units the engineering costs (*) will swamp the material costs so the point of staying under $1 is rather moot. A comparison between controllers between $8 and  $10 is way more interesting.

(*)for hobby: compare spending the extra time needed due to device limits and working the same time at the local grocery store.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ataradov on July 30, 2017, 06:46:12 pm
You can add SAMD11, it is still under $1, but has USB.

But, yes, I agree, it will be a real waste of time.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on July 30, 2017, 06:57:00 pm
Seems like a lot of work for something that will be of fairly limited use as everyone's requirements will be different.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: tszaboo on July 30, 2017, 07:19:59 pm
I don't see the value in such a test. At 100 units the engineering costs (*) will swamp the material costs so the point of staying under $1 is rather moot. A comparison between controllers between $8 and  $10 is way more interesting.

(*)for hobby: compare spending the extra time needed due to device limits and working the same time at the local grocery store.
Well, I think it makes sense, for some special niche. Like making a kickstarter, where you would rather keep the cost low, and you are fine for spending more time, because it is a hobby.

i would include some "reference" low cost micros, like Atmega328, STM32F103, Atmega32u4 ... for the reference. What do you get, if you pay more.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 07:37:49 pm
I think you're all focusing on the price / quantity for the wrong reason. In no way am I saying that you should swap out your $5 MCUs for $1 ones to save money at 100 unit quantity production run. Obviously that would be ridiculously stupid.

It's more like, "hey, what's out there these days, in 2017? What do all these manufacturer's development environments look like? If you're starting a new, long-term project, what parts should you consider?"

I picked "100 units" because it's sort of where pricing trends start to happen. It's a quantity that professionals and hobbyists can both wrap their heads around. And it's also small enough that it avoids shopping / negotiating directly with an MCU vendor. Look, last time I did a high-volume commercial product, I called up NXP and told them what I wanted to pay for their MCUs. So looking at quantities of 1k, 10k or 100k gets more challenging, because it really depends on your relationships with the vendors.

And I picked $1 price point because without a price limit on this comparison, it's overwhelming to whittle things down. These days, $1 buys you a mid-range, general-purpose basic microcontroller that's got dozens of I/O, half a dozen or more PWM channels, 10 or 12 bit ADC, decent sets of timers, and enough flash and RAM to cover most general-purpose entry-level needs. Personally, I think limiting price to $1 is a great way to give people some intuition about these families — and if you need more, you can always shop up in price, as most of these families are quite large, and vary quite little as you get up into the $10 price (from a broad perspective, what's the difference between the STM32F0 ecosystem and the STM32F4 ecosystem? Not much)

Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on July 30, 2017, 07:40:03 pm
I don't see the value in such a test. At 100 units the engineering costs (*) will swamp the material costs so the point of staying under $1 is rather moot. A comparison between controllers between $8 and  $10 is way more interesting.

(*)for hobby: compare spending the extra time needed due to device limits and working the same time at the local grocery store.
Well, I think it makes sense, for some special niche. Like making a kickstarter, where you would rather keep the cost low, and you are fine for spending more time, because it is a hobby.
I disagree. For a kickstarter you will want the product ready on time. The idea is out there so the competition is watching.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: tszaboo on July 30, 2017, 07:46:22 pm
I disagree. For a kickstarter you will want the product ready on time. The idea is out there so the competition is watching.
Anyone smart enough would develop the hardware prototype, including the firmware, before going for kickstarter. The really smart people only release a 3d render, and get millions for a not feasible idea though.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 07:49:39 pm
And one cannot look to vendor supplied or even distributor supplied literature to give an honest picture of the relative merits and demerits of brand A model B MCUs vs brand C model D MCUs except in a cherry picked "See, ours is way better!" examples that may not be overall an honest / full picture.

So given that yeah I'd often have liked to see an EE-Wikipedia or whatever "MCU comparison review" Anandtech style review of the real good / bad points of particular MCUs vs. others that goes into some depth of use cases.
Yes! You hit the nail on the head. The other thing I noticed is that the internet is full of these engraved-in-stone beliefs ("ARM always beats 8-bit", "AVR is faster than everything else because it's single-cycle", "8051 is old and shouldn't be used", "It doesn't make sense to learn a new MCU if you can help it"), and in my testing, many of them evaporate.

Early observations (not finalized!):
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on July 30, 2017, 07:50:09 pm
The really smart people only release a 3d render, and get millions for a not feasible idea though.
LOL!  :-DD
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 07:58:54 pm
If you are kickstarting, and plan to offshore your production, my suggestion is to try STM8, STM32 and STC.
Or even if you're a hobbyist working here. The STC, dollar-for-dollar, looks fantastic when compared to other 8-bit MCUs. They have decent English datasheets, and their parts are readily available on Ali Express, which many U.S. shoppers are becoming comfortable using, and Taobao (which hardcore shoppers are fine wtih). All STC parts have a UART bootloader and UART debugging (via a monitor program), so if you've got a USB-to-UART dongle laying around, that's all you need. Developing in Keil is much grosser than the Silicon Labs' 8051 parts, though, which use their free, Eclipse-based IDE — while still calling the (excellent) Keil C51 compiler under the hood.

The STM8 is a fantastic microcontroller that ships with a great peripheral library, and has many features found only on Cortex MCUs (slew rate / drive strength, lots of clocking options, and a nice core design). Biggest problem for me is that STVD feels like it belongs in Windows 98.

STM32F0 is pretty average when compared to other Cortex-M0 parts, but it's really cheap in China, and, like the STM8, supports $5 ST-Link debugging. Lots of good, free, Eclipse-based tools.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ataradov on July 30, 2017, 07:59:31 pm
Siliicon Labs' 8051s are cycle-for-cycle similar to the AVRs in performance, but run at much higher clock rates.
8051 will lose just because of a single accumulator. C compilers suck at dealing with that.

The Renesas RL-78 is one of the best MCUs in this price range (considering performance and power consumption), has fantastic free dev tools, and it's virtually unheard of in the U.S.
But if you do have a problem, good luck getting any support. Manufacturer will not respond unless you are buying millions, and there is no public support, since nobody uses them in hobby and small scale projects.

Different M0 vendors seem to have quite different
interrupt structures for their peripherals, which can affect latency hugely
interrupt latency is defined by the core. Structure of interrupt source may result in needing to handle more interrupts to achieve the same goal though.

ARM-GCC produced much faster (but much larger code) in all my tests when compared to MDK using comparable optimization settings. No flame war until final testing is finished, please.
Try it with LTO. On big projects I see 10-20% reduction in size.

PS: I'm pretty set on ARM parts, I'm not moving to anything else unless there is a HUGE advantage. Anything else just not worth my time and hassle.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 08:10:04 pm
8051 will lose just because of a single accumulator. C compilers suck at dealing with that.
It's funny that you're literally doing exactly what I was just making fun of — people applying old, tired opinions that don't necessarily hold up in 2017.

While what you said was true of compilers when the AVR was designed, it's not necessarily true in 2017. In fact, the fact that the 8051 has fine-grained balance between data space and access time (MOVs and operations can take 1, 2, or 3 cycles to execute -- basically the number of bytes long the instruction is -- based one where the data is) gives you control over performance, in many scenarios. In my testing, an ATTiny and an EFM8 were both tested with identical code to perform high-pass filtering using a 16-bit direct form I biquad implementation. They have almost identical performance numbers. This largely comes down to memory access, with Silicon Labs' pipelined core structure helping edge it out over the ATTiny. To add insult to injury, the EFM8 at the same price point runs at 72 MHz from an internal oscillator, while the ATTiny can only hit 8 MHz from an internal oscillator. And the EFM8 @ 72 MHz uses less power than an ATTiny @ 8 MHz. Obviously, this was *one test* and the results are preliminary.

Of course, Cortex-M0 parts that cost the same have come in and wrecked both of these in terms of raw processing performance and nJ-per-sample power consumption figures (but not power consumption in wait/sleep modes!)

Again, not starting a flame war -- there's lots and lots and lots of good reasons to pick an AVR part, but just make sure to check your numbers before you talk about performance or power consumption.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 08:15:42 pm
PS: I'm pretty set on ARM parts, I'm not moving to anything else unless there is a HUGE advantage. Anything else just not worth my time and hassle.

Which ARM part, though? I'm testing eight of them. All have wildly different performance, features, and development ecosystem friendliness.

Also, there's a lot of applications where I've spent way more time hassling with low-power modes trying to get an ARM microcontroller to get near what I get on a low-power 8-bit guy. It always comes down to the application.

I think you're going to love reading my write-up when I'm finished.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ataradov on July 30, 2017, 08:15:56 pm
It's funny that you're literally doing exactly what I was just making fun of — people applying old, tired opinions that don't necessarily hold up in 2017.
I should probably rephrase my statement: "Free and open C compilers suck at dealing with that.". I have no doubt that proprietary win-only compiler may have improved. I personally don't care, I don't want to be stuck in a hell of proprietary tools.

And there is no reason to spend a whole lot of effort on making 8051 work, IMO.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 08:19:24 pm
I should probably rephrase my statement: "Free and open C compilers suck at dealing with that.". I have no doubt that proprietary win-only compiler may have improved. I personally don't care, I don't want to be stuck in a hell of proprietary tools.
"Open" you're not going to get with Keil, but free? Yes. Silicon Labs gives away full versions of Keil's C51 compiler when you install their free Eclipse-based IDE, Simplicity Studio. And, it's completely cross-platform — which should entice some hobbyists to check it out, since they tend to be on macOS / Linux more often than other developers.

And there is no reason to spend a whole lot of effort on making 8051 work, IMO.
600 nA sleep current, with RAM retention, with an RTC running.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ataradov on July 30, 2017, 08:22:01 pm
Which ARM part, though?
Well, I work for Atmel/Microchip, and I do like SAM parts (SAM D specifically). I used STM32 a lot in the past, and have no problems with them either.

All have wildly different performance, features, and development ecosystem friendliness.
I only do bare-metal, so vendor ecosystem is not a problem, they all universally suck. And requirement for performance is very specific to a project. I doubt there is a way to do a good chart-like comparison. There may be details that may make or break a project that you will not notice without extensively using the part.

Also, there's a lot of applications where I've spent way more time hassling with low-power modes trying to get an ARM microcontroller to get near what I get on a low-power 8-bit guy. It always comes down to the application.
This is true at times, but much less in recent years. And in my experience ARM datasheets are much more honest about their power consumption numbers.

I never had a problem hitting datasheet number straight out of the box. With AVRs I had to dick around a lot to get anywhere close to the claimed number.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ataradov on July 30, 2017, 08:29:43 pm
"Open" you're not going to get with Keil, but free? Yes.
Until they change their mind (or contract expires), and then you are screwed.

Keil already scaled down maintenance on anything but ARM after acquisition my ARM. It is a matter of time until they kill it entirely.

600 nA sleep current, with RAM retention, with an RTC running.
This is so far the best argument, but ARMs nowadays are mostly ~2 uA sleep under the same conditions. And the gap narrow every year.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on July 30, 2017, 08:58:19 pm
This is so far the best argument, but ARMs nowadays are mostly ~2 uA sleep under the same conditions. And the gap narrow every year.
The ARMs are actually getting worse for their sleepy state consumptions. At the finer geometries they are moving to its really hard to to get the leakage as low as at, say, 180nm or 130nm. There might be breakthroughs. 180nm leaked like a seive in the early days, but most makers managed to get very respectable leakage later on. Right now the 90nm, 65nm and 45nm geometries being used for new MCUs are still comparatively leaky.
 
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on July 30, 2017, 09:12:20 pm
"Open" you're not going to get with Keil, but free? Yes.
Until they change their mind (or contract expires), and then you are screwed.

Keil already scaled down maintenance on anything but ARM after acquisition my ARM. It is a matter of time until they kill it entirely.
If you get a license which never expires and can be installed on any PC then you won't need Keil's support. I have used Keil's compiler for 8051 and I must say it does a pretty good job. Still like any architecture similar to the 8051 (like 8 bit PIC) you have to write C code with the architecture in minder otherwise the code will be extremely slow.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on July 30, 2017, 10:05:18 pm
Of course, Cortex-M0 parts that cost the same have come in and wrecked both of these in terms of raw processing performance and nJ-per-sample power consumption figures (but not power consumption in wait/sleep modes!)
Also cortex M at such price don't have such interesting peripherals. For example, with EFM8UB1 I can get MCU with crystal-less USB, 5V tolerant GPIO, internal 3.3V voltage regulator which can supply up to 100 mA to external devices and 12 bit ADC for around $0.60 @100pcs. That is pretty amazing.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: NorthGuy on July 30, 2017, 10:36:29 pm
I think making such comparison is a brilliant idea. Don't forget to post the results.

I found you one of the newest PIC18s for 99 cents:

http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18LF24K40-I/SS (http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18LF24K40-I/SS)

Unfortunately PIC16F1454 with USB didn't make it under the dollar limit.

If you want to measure sleep current on PICs, use LF versions instead of 5V versions, e.g. PIC16LFxxx instead of PIC16Fxxx - they have sleep current in nA.

Also, traditional benchmarks do not reflect performance very well. You may try something non-traditional, e.g. how fast you can toggle a pin, how fast you can squash a bug - e.g. change an output in response to the rising edge on input, how fast you can send/receive UART etc. Although, even then you'll be mostly evaluating C compilers rather than chips.

Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 30, 2017, 11:07:34 pm
I think making such comparison is a brilliant idea. Don't forget to post the results.
Absolutely! I'm writing up an extensive section of pages on my blog which will have a large comparison piece, along with separate in-depth reviews and analysis for each family, which will include "gotchas" that each platform inevitably has, along with some qualitative discussion about available IDEs, peripheral libraries, documentation, and other resources.

I found you one of the newest PIC18s for 99 cents:

http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18LF24K40-I/SS (http://www.microchipdirect.com/ProductSearch.aspx?Keywords=PIC18LF24K40-I/SS)
Oooh, thanks for the link — I looked for a PIC18 under a buck and couldn't immediately turn something up. Will add this to the list.

If you want to measure sleep current on PICs, use LF versions instead of 5V versions, e.g. PIC16LFxxx instead of PIC16Fxxx - they have sleep current in nA.
Yup, using the LF parts for everything, since all benchmarking and power measurements will be conducted at 3.3V (sorry, AVR).

Also, traditional benchmarks do not reflect performance very well. You may try something non-traditional, e.g. how fast you can toggle a pin, how fast you can squash a bug - e.g. change an output in response to the rising edge on input, how fast you can send/receive UART etc. Although, even then you'll be mostly evaluating C compilers rather than chips.

Totally agree! Just to get into a little bit more of the mechanics of what I'm doing, in addition to comparing specs, I'm doing three code-oriented tasks on each platform:
Title: Re: $1 MCU review — looking for part suggestions!
Post by: NorthGuy on July 30, 2017, 11:18:58 pm
  • Implement a DMX-512 receiver attached to an RGB LED; minimize power consumption by using wait states and low-frequency clocking.
PIC18LF24K42 has built-in hardware DMX support, but it is out of your price range by few cents.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on July 30, 2017, 11:45:40 pm
Quote
(especially when you have that one extra quirk — that DMX-512 requires detecting a framing error as a 'start of frame' indicator, and some peripheral libraries / code-gen tools don't do this for you).
Breaks can get interesting when you have a FIFO'd UART, and a UART error interrupt. I don't recall the CPU but I've seen a situation where the error int happens when the UART is still in the FIFO behind some data.
This caused an issue only with DMX coming from I think a Pharos unit, which sent the break immediately after the last byte of the previous frame.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 31, 2017, 12:13:20 am
Breaks can get interesting when you have a FIFO'd UART, and a UART error interrupt. I don't recall the CPU but I've seen a situation where the error int happens when the UART is still in the FIFO behind some data.
This caused an issue only with DMX coming from I think a Pharos unit, which sent the break immediately after the last byte of the previous frame.
Haha, it's really serendipitous that you should mention that. The Nuvoton M051 part I just finished testing on last night had this issue. I created a bit of a weird state-machine that sets the FIFO to 1 byte until a framing error happens, and then increases the FIFO to 14 bytes, until it gets halfway through, and then resets it to 1 again. This way I can start receiving at an arbitrary period of time and still use the FIFO.

...of course, once I did all that, I lowered the clock rate to the minimum (which is still pretty high -- it's only a divide-by-16 system divider from a 22 MHz internal oscillator), and the system could easily handle the single-byte reception, thus making the whole thing pointless in this particular application :-)

The wait states in the main busy loop helped a ton with overall power consumption, but didn't change anything at all with or without the FIFO enabled.

I want to go back and use the Renesas RL-78's DMA (yes, a 60-cent 8-bit MCU with DMA!) to see if it changes the power consumption, but at 500 µA, it's currently leading the pack (lots more to review, though, and I've basically only been doing industrial-targetted MCUs that don't have good power figures).

I can't wait to finish testing all the Cortex-M0 MCUs, since the two that I've tested so far — the Freescale/NXP KL03 and the Nuvoton M051 — have vastly different interrupt routine timings with respect to the UART. The KL03 didn't raise an interrupt until halfway through the next byte, and it took about 70% of the byte period to get through the ISR. The Nuvoton part, running at the same frequency, took no time at all — maybe 1/15th of the period. Same core, same interrupt system. Must have vastly different UARTs with different latencies. Totally different power consumption figures, too.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on July 31, 2017, 10:11:25 am
Quote
Silicon Labs gives away full versions of Keil's C51 compiler when you install their free Eclipse-based IDE, Simplicity Studio. And, it's completely cross-platform
Does the SI license say you can use the compiler they provide on other vendors' chips, or are you just engaging in a subtle form of piracy?

The whole comparison thing might be more interesting if done at more price levels (perhaps with fewer chips at each price level.)  In general, I feel like I have a much better idea about what a "typical" $1 microcontroller will do than "do you get 5x or 10x the capabilities with a $5 or $10 microcontroller?"  (and a comparison at the $15 level (near the top-of-the-line for AVRs) is a lot more dramatic in some ways.  The 8bit chips are about 256k flash and 8k of RAM, while the 32bit chips are up at 1MB flash and 256k of RAM!)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: gamalot on July 31, 2017, 12:24:02 pm
A few days ago I bought some STM32L011D4P6TR for about $0.97/pc on Taobao.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Yansi on July 31, 2017, 05:52:49 pm
Of course, Cortex-M0 parts that cost the same have come in and wrecked both of these in terms of raw processing performance and nJ-per-sample power consumption figures (but not power consumption in wait/sleep modes!)
Also cortex M at such price don't have such interesting peripherals. For example, with EFM8UB1 I can get MCU with crystal-less USB, 5V tolerant GPIO, internal 3.3V voltage regulator which can supply up to 100 mA to external devices and 12 bit ADC for around $0.60 @100pcs. That is pretty amazing.

Look at STM32F042.  ;)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 31, 2017, 07:17:43 pm
Does the SI license say you can use the compiler they provide on other vendors' chips, or are you just engaging in a subtle form of piracy?
Of course it's restricted to SI chips. While I recently wrote a blog post about using Simplicity Studio (thus, Keil C51) to program a 35-year-old MCU (https://jaycarlson.net/2017/06/27/blinking-an-led-with-an-original-intel-8051/), it was done more as a fun exercise — it would be dishonest to program other 8051s in Simplicity Studio with the unlimited Keil license; especially for commercial purposes.

There's also not much reason to; most other 8051s are inferior to SiLabs' parts, and aren't much cheaper (if at all) — especially for people developing outside of China.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on July 31, 2017, 07:25:48 pm
Of course, Cortex-M0 parts that cost the same have come in and wrecked both of these in terms of raw processing performance and nJ-per-sample power consumption figures (but not power consumption in wait/sleep modes!)
Also cortex M at such price don't have such interesting peripherals. For example, with EFM8UB1 I can get MCU with crystal-less USB, 5V tolerant GPIO, internal 3.3V voltage regulator which can supply up to 100 mA to external devices and 12 bit ADC for around $0.60 @100pcs. That is pretty amazing.

Look at STM32F042.  ;)
Well, I looked on it briefly  :(. Costs more than twice as much. No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs). UB1 comparator also has programmable hysteresis.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 31, 2017, 07:33:55 pm
In general, I feel like I have a much better idea about what a "typical" $1 microcontroller will do...
You have good intuition about that? I don't — and I think a lot of people don't, either. There's a lot of opinions floating around, but not a lot of facts.
"do you get 5x or 10x the capabilities with a $5 or $10 microcontroller?"  (and a comparison at the $15 level (near the top-of-the-line for AVRs) is a lot more dramatic in some ways.  The 8bit chips are about 256k flash and 8k of RAM, while the 32bit chips are up at 1MB flash and 256k of RAM!)
Excluding the Propeller and XMOS and a few other weird architectures, most every family has a $1 entry on my list, so once you compare the base members, you're good. If you want to compare flash densities or other basic parametrics, just hop on DigiKey or something.

Those things don't interest me as much as development environment, code-gen tools, peripheral libraries, development hardware, performance, peripherals, and power consumption — but hey, the Internet is big enough for both of us! Maybe start a parametrics comparison project?
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on July 31, 2017, 07:37:38 pm
Look at STM32F042.  ;)
Well, I looked on it briefly  :(. Costs more than twice as much. No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs). UB1 comparator also has programmable hysteresis.
On the bang-for-your-buck metric, you ain't gonna beat an EFM8UB1. For typical USB full-speed devices, it's nearly perfect.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Yansi on August 01, 2017, 08:19:28 am
Look at STM32F042.  ;)
Well, I looked on it briefly  :(. Costs more than twice as much. No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs). UB1 comparator also has programmable hysteresis.
On the bang-for-your-buck metric, you ain't gonna beat an EFM8UB1. For typical USB full-speed devices, it's nearly perfect.

Maybe from the buck point, otherwise no, nope.  But it is interesting MCU.
What I do not understand is the price point the 32F042 is usually sold at 1-off quantities at the usual distributors. As I do know for what price it is usually sold at quantities (not that large), it is kind of mind boggling. (but not only with this one)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on August 01, 2017, 09:34:04 am
You have good intuition about that? I don't — and I think a lot of people don't, either. There's a lot of opinions floating around, but not a lot of facts.
  • Is a 24 MHz Cortex-M0 is faster or more efficient than a same-price 72 MHz 8051?
  • Does PIC's super-high clock rate + low-power make it comparable to the more-efficient-clock-cycle AVR? Better? Worse?
  • I know code density is worse on Cortex-M0 chips, but how much worse? What happens when you factor in all the manufacturer-supplied peripheral libraries?
  • Are 16-bit MCUs a "sweet spot" between the 8-bit and 32-bit guys, or just a waste of time? What about weird 16/8-bit hybrids, like the Renesas RL78 that has 8-bit data paths, but a 16-bit ALU?
  • Honestly, is there even a reason to mess with 8- and 16-bit MCUs? Should everyone just use Cortex-M0s for low-end stuff?
  • Which manufacturers have the best IDEs? Code-gen tools? Peripheral libraries?
Title: Re: $1 MCU review — looking for part suggestions!
Post by: legacy on August 01, 2017, 09:46:20 am
Try running some C code that uses the full power of the language - lots of structure manipulation, and so on - and 8051 code from the best compilers looks pretty bad. So, speed depends a lot on the kind of code you are running

It's the same on 68hc11
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 01, 2017, 03:13:50 pm
A real 12-cycle 8051 core is always pretty slow. With a modern single cycle 8051 core code that's heavy in bit banging can be really fast and dense. However, the code looks slower and more bloated as the complexity of the code increases. Try running some C code that uses the full power of the language - lots of structure manipulation, and so on - and 8051 code from the best compilers looks pretty bad. So, speed depends a lot on the kind of code you are running.

The PIC is largely in the same category as the 8051, with regard to what it does well and does poorly. The AVR runs most complex C code pretty well.
I was obviously referring to the modern, 1T 8051 cores on my list, like the three-stage pipelined EFM8 ones Silicon Labs makes. The Nuvoton N76 in my lineup is also a 1T 8051, but its instruction timing is quite a bit slower on critical instructions than the EFM8 stuff.

Do you have suggestions/recommendations for what, specifically, to run to illustrate this "complex C code"? As far as I understand, struct manipulation is the same thing to a compiler as array manipulation with immediate (const) offsets. Neither the 8051 or AVR has load/store instructions that take an immediate-offset parameter (IIRC? Correct me if I'm wrong!), which means they will perform similarly in this regard (8051 will be a cycle faster than AVR if the data is in RAM, and a cycle slower than the AVR if the data is in XRAM).

If you think M0 code is less dense, that might reflect the kind of code you have been looking at. Try some serious maths, and the M0 code should look far denser than any PIC or 8051 code. Pretty much anything using the real power of the 32 ALU should result in denser code.
Sure, obviously, but we're talking about microcontrollers, not GPUs. I'd say that most MCUs I program don't sit around in for() loops running filters all the time.

One 16 bit core which does hit a sweet spot is the MSP430. It does pretty well on bit banging. It does pretty well on compute. C compiles very well for it. I have seen people get pretty good results with some RL78 devices running full featured C code, but I don't have personal experience.
Totally agree; I had my first experience with the RL78 a few weeks ago, and I really, really enjoy working on it. And unlike the MSP430, it's priced to compete with 8-bit MCUs.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on August 01, 2017, 05:07:24 pm
On the bang-for-your-buck metric, you ain't gonna beat an EFM8UB1. For typical USB full-speed devices, it's nearly perfect.

Maybe from the buck point, otherwise no, nope.  But it is interesting MCU.
What I do not understand is the price point the 32F042 is usually sold at 1-off quantities at the usual distributors. As I do know for what price it is usually sold at quantities (not that large), it is kind of mind boggling. (but not only with this one)
Of course if you want to process a lot of data it might be not a best option. But it's perfect to build cost efficient HID devices. Like game controllers, joysticks and similar stuff. For example I can have a lot of analog channels sampled pretty fast. And the sweet part is due to built in VREG and versatility of ADC and analog comparators, I can keep the minimal number of additional components required compared to other much more expensive MCUs.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on August 01, 2017, 05:26:02 pm
I was obviously referring to the modern, 1T 8051 cores on my list, like the three-stage pipelined EFM8 ones Silicon Labs makes. The Nuvoton N76 in my lineup is also a 1T 8051, but its instruction timing is quite a bit slower on critical instructions than the EFM8 stuff.
Not all 1T 8051 cores are created equal, but the big deal is usually the memory controller. You can be sure the flash isn't keeping up with a 72MHz core. There is no cache to mask that slowness, so the cleverness of the flash controller can be a big deal in extracting good performance.
Do you have suggestions/recommendations for what, specifically, to run to illustrate this "complex C code"? As far as I understand, struct manipulation is the same thing to a compiler as array manipulation with immediate (const) offsets. Neither the 8051 or AVR has load/store instructions that take an immediate-offset parameter (IIRC? Correct me if I'm wrong!), which means they will perform similarly in this regard (8051 will be a cycle faster than AVR if the data is in RAM, and a cycle slower than the AVR if the data is in XRAM).
You could try compiling something like an open source protocol package. They typically make the 8051 look a bit sick.
Sure, obviously, but we're talking about microcontrollers, not GPUs. I'd say that most MCUs I program don't sit around in for() loops running filters all the time.
A large number of high volume MCU applications involve quite a bit of maths on 16, 32 or 64 bit numbers, although they seldom involve calculating it at high speed. A large number of apps actually drag in several k of floating point software library code, typically to expand the dynamic range of a few divisions. Most MCUs are actually run at way below their rated MHz. It one of the surprises you find when you get visibility of a large number of customer applications.
Totally agree; I had my first experience with the RL78 a few weeks ago, and I really, really enjoy working on it. And unlike the MSP430, it's priced to compete with 8-bit MCUs.
The MSP430 competes head on with the RL78 on price, if you buy enough of them. They don't price them very well for small volume applications.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on August 01, 2017, 06:04:23 pm
Not all 1T 8051 cores are created equal, but the big deal is usually the memory controller. You can be sure the flash isn't keeping up with a 72MHz core. There is no cache to mask that slowness, so the cleverness of the flash controller can be a big deal in extracting good performance.
EFM8 can run directly from flash with up to 25MHz core clock. Anything higher must have prefetch enabled.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 01, 2017, 06:11:36 pm
I feel like I came across a lower-cost MCU with 50 MHz flash access recently, but I can't seem to remember which one. Does anyone have any leads?

I was thinking it was the Cypress PSoC 4000S, but it looks like it has pretty typical flash memory that requires two wait-states at 48 MHz.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Bruce Abbott on August 01, 2017, 08:53:28 pm
The only rule is that the part has to be $1 or less @ 100 units from reputable sources

Quote from: Yansi
    Look at STM32F042.  ;)

Well, I looked on it briefly  :(... No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs).
Changing the rules?

That particular chip might be out of your (arbitrary) price range, but now you are adding even more limitations. The industry is moving away from 5V, and many 3.3V MCUs are not 5V tolerant on analog inputs - for obvious reasons. Peripherals you don't need are just a waste of silicon and raise the price for no good reason.

Quote
The review will include quantitative comparisons between feature sets, benchmarking (via a 16-bit biquad filter test measuring kSPS and nJ/sample), power analysis, plus more qualitative stuff (development environment, SDKs, compiler choices, development/debugging experience, etc)...
This is silly. A fair comparison would take months if not years, by which time your 'review' will be way out of date.

It sounds like you have some specific applications in mind. If so then you should make a short list of chips that have the features you need, choose one, and see if it will do the job. Then (if you want to) tell us about it. Bonus points for choosing an obscure MCU that most people wouldn't consider.

But if you are just trying to organize a 'shootout' to see which MCU is 'best' then don't bother - unless you have a lot of time to waste. 
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on August 01, 2017, 10:45:12 pm
The only rule is that the part has to be $1 or less @ 100 units from reputable sources

Quote from: Yansi
    Look at STM32F042.  ;)

Well, I looked on it briefly  :(... No internal 5V -> 3.3V regulator, ADC capable inputs are not 5V tolerant. To use it with USB, instead of just a few decoupling caps I would need to use external VREG. ADC is much less versatile, no analog gain adjustment (0.5/1). Only single 1.25V reference voltage (1.65V and 2.4V for UB1). No analog comparator, UB1 has 2 of them, no internal DAC (used with comparators, both inverting and non-inverting inputs).
Changing the rules?

That particular chip might be out of your (arbitrary) price range, but now you are adding even more limitations.
Which rules? I briefly mentioned what is good in this MCU. You made a post to look for STM32F042. Then I compared them and noticed that STM32F042 is very limited in analog part. Even without analog part, and limited 5V tolerance, lack of 5V-3.3V vreg and much higher price is a showstopper.
Quote
The industry is moving away from 5V, and many 3.3V MCUs are not 5V tolerant on analog inputs - for obvious reasons.

USB provides 5V, just for this reason I want it to be 5V tolerant.
Quote
Peripherals you don't need are just a waste of silicon and raise the price for no good reason.
Rise of price? Did not notice that for UB1. What is a waste, is need to use numbers of external components which could be avoided. I can connect UB1 to usb directly, connect analog inputs to just anything without circuity to adjust voltage levels and call it a day. Not the case of F042.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 02, 2017, 12:11:25 am
Changing the rules?

That particular chip might be out of your (arbitrary) price range, but now you are adding even more limitations. The industry is moving away from 5V, and many 3.3V MCUs are not 5V tolerant on analog inputs - for obvious reasons. Peripherals you don't need are just a waste of silicon and raise the price for no good reason.
I am not @wraper. I don't care about 5V tolerant inputs. I'm testing everything at 3.3V. Most of these parts are 5V-tolerant digitally, but obviously use clamp diodes which prevents analog signals from getting too hot. Not really testing this, though it's a good idea to mention it — I'll make sure to.

The price range is arbitrary, but not unwarranted. If you start going above $1, you start heading off into application-specific land: this part has an LCD controller, that part has better DMA, this part has CAN, that part has QSPI, blah blah blah... I don't want to open that can of worms because:

A fair comparison would take months if not years, by which time your 'review' will be way out of date.
Unless you limit it to general-purpose MCUs with similar-ish peripherals, and limited test code. Hence, more reasons for $1 price limit.

It sounds like you have some specific applications in mind. If so then you should make a short list of chips that have the features you need, choose one, and see if it will do the job.
This is what I've done every time I've started a new project, but I'm tired of not having data that I can use to make these decisions. Also, I don't have a "specific application" in mind — other than "general purpose, entry-level." Look, I've built surgical robotics motor controllers, data logging platforms, localization systems, embedded Linux systems, deep-low-power underground sensors, and basically everything in between. Please get off your high horse and agree with me that there is a *large* class of embedded designs that my list of $1 general-purpose entry-level MCUs is great for. If you can't agree with that, then I don't know why you're even posting on this thread.

But if you are just trying to organize a 'shootout' to see which MCU is 'best' then don't bother - unless you have a lot of time to waste.
Go away. You're being mean and unhelpful.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on August 02, 2017, 01:38:57 am
Quote
Quote
and a comparison at the $15 level is a lot more dramatic in some ways.
... once you compare the base members, you're good.
I think I strongly disagree.   One of the important factors, even when considered a $1 chip, is the potential for transitioning to a more powerful chip without having to start over.  This leads to some depressing facts where you're NOT good if you understand the low end.
Consider RAM.  None of the 8-bit PIC architecture chips can address more than 4k of RAM.   Few 8bit microcontrollers have as much as 16k of on-chip RAM, and even if they're "capable", you start running into restrictions - For example, "such-and-such banking scheme isn't support transparently by anything except xyz compiler", or isn't supported at all...  (This applies to program memory as well.  I like both the AVR and MSP430s, but neither is something I'd use if I thought I might someday need more than 64k...)
Also, between chip complexity and vendor libraries, a lot of the 32bit chips being offered as 8bit replacements (ie the ones that fall in your price range) are a bit disappointing as well.  I don't think I believe that a 16k SAMD10 is going to be an adequate replacement for a 16k AVR, for example.  The usual answer for ARM chips is "just use a chip with more memory; they're still cheap."  That's moderately true, but ... there are no samd10-pinout chips with more than 16k.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: NorthGuy on August 02, 2017, 02:08:34 am
None of the 8-bit PIC architecture chips can address more than 4k of RAM.

This is a lot of RAM. You can do a lot with it. There are many projects where you need much less RAM. Of course, it is not enough for graphic LCD controller, but you wouldn't think of building LCD controllers with 8-bit MCUs.

Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 02, 2017, 03:34:43 am
One of the important factors, even when considered a $1 chip, is the potential for transitioning to a more powerful chip without having to start over. 
What you're saying is true, and I'm definitely going to mention how much headroom these parts have — but honestly, once you have the base members down, it's just parametrics after that. A 128 KB AVR is going to perform the same way in my testing as an 8 KB AVR. Are you worried about falling in love with a $1 microcontroller that doesn't have much headroom? Total possibility, since some of these families are really niche to this price range.

But my whole thing with this series is that it's 2017 — code-gen tools are better and easier-to-use than ever, and peripheral libraries are really great, too. Most of the IDEs aren't proprietary anymore, compilers are free, and debuggers and dev boards are <$50. It's obviously not trivial to swap MCUs in the middle of a complex product, but I hope this project encourages people to think of MCUs as commodity items that can be freely selected, without having to pay a huge penalty for working with a new chip.

This project isn't about finding the ONE microcontroller to rule them all — I'm not even going to declare a "winner" in this series — instead, it's about getting people comfortable with everything that's out there. And honestly, everything I've done so far is proving that point. I've been banging through a different MCU each night I've been working on it, and only one chip has given me trouble (and, ironically, it's one of my favorite go-to that I've been using for the last two years now for projects in this price range). Everything else has been super straightforward to get up and running. I've been pleasantly surprised by chips I've written off, and getting annoyed by chips I'm super familiar with ("Why isn't that as easy as it was on that new chip I was working with last night...?"). It's been a huge learning experience for myself, and I hope a lot of other people gain a lot of intuition from it.

Keep the comments coming!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on August 02, 2017, 03:46:11 am
For <1$ you've absolutely got to add the Nordic Semi NRF51 to the list... A great little Cortex-M0 which comes with Bluetooth LE (and generic 2.4GHz) radio, the stack for that, pretty great SDK, and great open source (toolchain and library / RTOS) support these days. It's pushing the $1 limit but if you know the right distributor in China it can definitely be done for 100 units ;D
And of course there's the NRF52 range for "headroom".

Below that what's fascinating is the STM8S003F3P6 which is the cheapest microcontroller I've been able to find and pretty nice for that (already discussed in this thread). It's <0.2$ which opens up a whole other range of opportunities.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 02, 2017, 04:59:15 am
For <1$ you've absolutely got to add the Nordic Semi NRF51 to the list
Great chip, but totally, definitely, not even close to being <=$1. :P

Below that what's fascinating is the STM8S003F3P6 which is the cheapest microcontroller I've been able to find and pretty nice for that (already discussed in this thread). It's <0.2$ which opens up a whole other range of opportunities.
I'm actually working through the STM8 review as we speak! Great architecture — much more clock-cycle-efficient than any other 8-bitter that I've tested thus far (unless you count the RL78 an 8-bit MCU, even with its 16-bit ALU).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on August 02, 2017, 05:42:13 am
For <1$ you've absolutely got to add the Nordic Semi NRF51 to the list
Great chip, but totally, definitely, not even close to being <=$1. :P

(snip)

The last quote I got from my distributor was 7.8RMB in December of last year (all my recent projects have been using NRF52...), as far as I know the price has come down a bit since then so I do believe <1$ is possible. I saw a quote of 6.5RMB recently so that would put it over the threshold. Not delivered to outside China, of course, but for Kickstarter pricing etc...
You could always give it an "honorable mention" if you think that's too fuzzy, I guess ;)

But while I'm on the topic, we can't forget the ESP8266 either! A little bit of an odd one since you also have to add the EEPROM to the cost but I think it can just squeeze in at <1$: https://item.taobao.com/item.htm?spm=a230r.1.14.18.ebb2eb22ZgRGe&id=532682188102&ns=1&abbucket=2#detail
+ https://item.taobao.com/item.htm?spm=a230r.1.14.34.ebb2eb2LqPrU2&id=37750426961&ns=1&abbucket=2#detail
Title: Re: $1 MCU review — looking for part suggestions!
Post by: wraper on August 02, 2017, 06:48:43 am
Considering there are a lot of counterfeit nRF24L01 in the wild, I would be concerned about nRF51 too.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ali_asadzadeh on August 02, 2017, 07:58:39 am
Add STM32F103RBT6 to the list too an M3 with huge benefits! :)

https://world.taobao.com/item/42883572952.htm?spm=a312a.7700714.0.0.6419a3bcVpjLuq#detail
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on August 02, 2017, 07:05:06 pm
I love Taobao as much as the next guy, but for this series, I'm focusing on general-purpose MCUs from reputable, North American-based distributors, or directly from the company. And I'm trying to find the "best" (obviously subjective!) representative from each family, which typically means the representative from the family that is as close to $1 (without going over).

The main reason I'm doing it this way instead of including Taobao/AliExpress/eBay/weird Newark closeout specials is to make sure I'm judging "value" instead of just functionality. If all the parts I'm reviewing cost about the same, it's easy to look across the numbers and the reviews and identify good and bad values. Since a lot of these parts I'm reviewing (like the Nuvoton N76) struggle to hit $1 as it is, if I'm using Taobao pricing, at that point, I'd be comparing a $1 STM32F103 with 15- or 20-cent 8-bit MCUs, which doesn't seem useful for readers.

The actual, absolute price isn't particular important, as long as it's consistent across all the families. I could have easily said $2 @ QTY=1, or $0.80 @ 1000 units. It's just that $1 @ 100 units seemed like a nice sweet-spot for general-purpose MCUs.

And I think there's still a lot of value when operating with this constraint. For example, I hope that if you read my review of the STM32F0 and end up really liking the peripheral libraries, development ecosystem, and functionality of the part, you'll notice that you can get F103s on Taobao for cheap, and feel confident in the performance, functionality, and ease-of-development you'll get out of the part. That's how the series remains relevant to bigger/fancier chips, as well as making purchases from much cheaper markets.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: tszaboo on August 02, 2017, 08:23:10 pm
For <1$ you've absolutely got to add the Nordic Semi NRF51 to the list
Great chip, but totally, definitely, not even close to being <=$1. :P

https://world.taobao.com/item/541789410610.htm
Taobao no good for laowai. Buy digiii key.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on August 03, 2017, 01:55:03 am
I love Taobao as much as the next guy, but for this series, I'm focusing on general-purpose MCUs from reputable, North American-based distributors, or directly from the company. And I'm trying to find the "best" (obviously subjective!) representative from each family, which typically means the representative from the family that is as close to $1 (without going over).

The main reason I'm doing it this way instead of including Taobao/AliExpress/eBay/weird Newark closeout specials is to make sure I'm judging "value" instead of just functionality. If all the parts I'm reviewing cost about the same, it's easy to look across the numbers and the reviews and identify good and bad values. Since a lot of these parts I'm reviewing (like the Nuvoton N76) struggle to hit $1 as it is, if I'm using Taobao pricing, at that point, I'd be comparing a $1 STM32F103 with 15- or 20-cent 8-bit MCUs, which doesn't seem useful for readers.
(snip)

I think there is still value in mentioning which parts are popular in the Chinese supply chain (and I don't really mean taobao here, it's just useful as a barometer for market prices), since someone looking to choose a <$1 mcu is likely going to have to manufacture there anyway. Though, arguably, if they don't know the market well enough to know what the popular parts are already they probably need to do a bit more research first anyway before trying to build a low-cost product ;)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: donotdespisethesnake on August 03, 2017, 08:34:46 am
Add STM32F103RBT6 to the list too an M3 with huge benefits! :)

https://world.taobao.com/item/42883572952.htm?spm=a312a.7700714.0.0.6419a3bcVpjLuq#detail

Are GD32F103 CPUs on Taobao? I guess they are.. and probably a lot cheaper than STM32, maybe even < $1.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: donotdespisethesnake on August 03, 2017, 11:31:04 am
Add STM32F103RBT6 to the list too an M3 with huge benefits! :)

https://world.taobao.com/item/42883572952.htm?spm=a312a.7700714.0.0.6419a3bcVpjLuq#detail

Are GD32F103 CPUs on Taobao? I guess they are.. and probably a lot cheaper than STM32, maybe even < $1.

62 cents.

Nice :) At that price, I don't why I would bother with Cortex M0, 8 or 16 bitters, unless I had special requirements. I'm not quite ready to dive in to Taobao, maybe I should! I haven't been able to find GD32 outside of a few special distributors, nor even ebay or Aliexpress.

Title: Re: $1 MCU review — looking for part suggestions!
Post by: brucehoult on August 03, 2017, 03:23:04 pm
  • I know code density is worse on Cortex-M0 chips, but how much worse? What happens when you factor in all the manufacturer-supplied peripheral libraries?

Worse than what? Other Thumb2 chips? AVR?

Over the years, with programming many different architectures, I've come to the conclusion that 16 bit *instructions* are very much in a sweet spot, either fixed size, or with a way to escape to the occasional 32 bit instruction. That's regardless of whether the registers and data are 8 bit (AVR), 16 bit (PDP11 [1]), 32 bit (Thumb/Thumb2, RISC-V32C), or 64 bit (RISC-V64C).

32 bit instructions just have too much generality and wasted space. Sometimes you can use all the power (and aarch64 does a pretty good job), but sometimes you only want to negate a register and 32 bits is a waste for that.

Instructions based on 8 bit units seem like they should be better, especially as they can be better Huffman coded than instructions with larger granularity, but it just doesn't work out that way in practice, at least for x86, VAX, z80, 6502 etc. Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction. Both VAX and x86 need four bytes to do that. If the destination is the same as one operand then x86 can also do it in two bytes, but VAX needs three. 6502 needs 6 bytes (assuming 8 bit data and sources and destination in Zero Page). 8080/z80 need three bytes, assuming both operands and the destination are registers other than A (mov a,src1; add src2; mv dst,a).

[1] the actual instructions are all 16 bit, but some addressing modes have a side effect of loading an immediate or offset and advancing the PC
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Bruce Abbott on August 03, 2017, 05:29:32 pm
Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction. Both VAX and x86 need four bytes to do that. If the destination is the same as one operand then x86 can also do it in two bytes, but VAX needs three. 6502 needs 6 bytes (assuming 8 bit data and sources and destination in Zero Page). 8080/z80 need three bytes
This has less to do with instruction size than it does about which instructions are prioritized. The 8080 and Z80 waste most of their base opcodes doing 8 bit register to register transfers, then on the Z80 they had to add prefixes to expand the opcode range. 

The Z80 is is quite frustrating because many of the enhanced instructions have a cost far exceeding expectations. For example, here are 4 different ways to store the contents of the BC register in memory address $1234:-

Code: [Select]
1. copy B to A and C to A, store direct
79      ld  a,c
32 34 12 ld  (addr),a
78      ld  a,b
32 35 12 ld  (addr+1),a

2. store BC direct
ED 43 34 12 ld  (addr),bc

3. using HL as a pointer
21 34 12 ld   hl,addr
71      ld  (hl),c
23      inc  hl
70      ld  (hl),b

4. using IX as a pointer with offset (IX preloaded with base address)
DD 71 00  ld   (ix+0),c
DD 70 01  ld   (ix+1),b

2. is the shortest and most efficient, but could be even shorter if it didn't need the 'ED' prefix.

4. is the most versatile and convenient, but again wastes bytes on prefixes. And since indexed instructions work on 8 bit quantities only (no "ld (ix+0), bc") the code is 3 times the size it could be.
 
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on August 03, 2017, 06:22:35 pm
Quote
I've come to the conclusion that 16 bit *instructions* are very much in a sweet spot, either fixed size, or with a way to escape to the occasional 32 bit instruction.
Somewhat agree...

Quote
32 bit instructions just have too much generality and wasted space.
Whether "wasted space" is a problem is a technology issue.  My favorite instruction set of all time used a 36bit instruction word.  A memory/register architecture, each instruction had 9bits of opcode, 4 bits of register address, 4 bits of index register, and 18bits of "offset" (or constant.)  It had MANY no-op instructions, 64 system call instructions (half for user-implemented instructions...

Quote
Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction.
Well, mostly it doesn't.  Thumb has about 2 instructions (add and sub) that fit all three operands into 16bits.  And even then, it's done by reducing the number of registers that can be access to only 8.  (if 16bits is a sweet spot for instruction size, I think 16 is the sweet spot for usable registers (perhaps including PC, SP, and PSW.)   The whole "compress a 32bit instruction into 16bits" thing is clever, but I wish it had been a less "lossy" compression.   The CM0 (with only 16bit thumb instructions) is pretty ugly - if users hadn't been lulled into a sense of comfort by the full 32bit arm instructions and the less lossy Thumb-2 instructions, they wouldn't have been impressed :-(   (It's hidden by compilers and obscured by documentation, but if you try to program a CM0 in assembly language, or start actually look at the code your compiler produces, you quickly run into "this instruction form isn't supported" or "this offset/immediate value has a very limited range" and such.  grr.)


Quote
The Z80 is is quite frustrating because many of the enhanced instructions have a cost far exceeding expectations.
(ah - quite similar to the Thumb problem...)
Yeah; that was one of the two big nails in the coffin for classic CISC architectures.  (the other one was that compiler writers couldn't figure out how to make generic compilers USE all the fancy instructions.   The previously-mentioned 36bit CPU added enhanced string and bcd instructions at one point, but they required that you set up 4 to 6 register beforehand, and didn't really execute any faster than a tight loop of simpler instructions...
Title: Re: $1 MCU review — looking for part suggestions!
Post by: brucehoult on August 03, 2017, 06:44:23 pm
Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction. Both VAX and x86 need four bytes to do that. If the destination is the same as one operand then x86 can also do it in two bytes, but VAX needs three. 6502 needs 6 bytes (assuming 8 bit data and sources and destination in Zero Page). 8080/z80 need three bytes
This has less to do with instruction size than it does about which instructions are prioritized. The 8080 and Z80 waste most of their base opcodes doing 8 bit register to register transfers, then on the Z80 they had to add prefixes to expand the opcode range. 

Yes.

Instructions that are  byte-encoded *would* allow you to Huffman code the instructions (i.e. giving the most frequently used instructions the shortest opcodes, and give seldom-used things longer opcodes). But in fact they all failed to do that. Instead, they gave the instructions that need the fewest arguments or have the fewest options the shortest encodings -- because they don't seem to "need" more -- regardless of how infrequently they are used.

The absolutely classic example is the 8086's AAA instruction: Ascii Adjust AL After Addition, opcode 0x37. This is an instruction so frequently used that gcc doesn't even know how to emit it (without inline assembly language, at least). And yet it and its friends AAS (0x3F), DAA (0x27), DAS (0x2F) together take up 1/64 or 1.56% of the single byte instructions.

I guarantee they don't make up 1.56% of instructions in most programs.

Similarly, does HLT (0xF4) really need a 1 byte opcode? Or the instructions to set or clear carry/interrupt/direction (0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD). Or Complement Carry Flag (0xF5)?

That's 12 instructions now ... 4.7% of the opcode space. Every one of which could have happily had a two or three byte opcode without causing any real program a size problem.

There are plenty of examples left!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: brucehoult on August 03, 2017, 08:07:22 pm
Quote
I've come to the conclusion that 16 bit *instructions* are very much in a sweet spot, either fixed size, or with a way to escape to the occasional 32 bit instruction.
Somewhat agree...

Quote
32 bit instructions just have too much generality and wasted space.
Whether "wasted space" is a problem is a technology issue.  My favorite instruction set of all time used a 36bit instruction word.  A memory/register architecture, each instruction had 9bits of opcode, 4 bits of register address, 4 bits of index register, and 18bits of "offset" (or constant.)  It had MANY no-op instructions, 64 system call instructions (half for user-implemented instructions...

Quote
Thumb fits a 3-address add or subtract (destination register, and two source registers) into a two byte instruction.
Well, mostly it doesn't.  Thumb has about 2 instructions (add and sub) that fit all three operands into 16bits.  And even then, it's done by reducing the number of registers that can be access to only 8.  (if 16bits is a sweet spot for instruction size, I think 16 is the sweet spot for usable registers (perhaps including PC, SP, and PSW.)

16 or 32 registers total is good, but it's usually not too hard for a compiler to get all the important variables in a loop of even many functions into 8 registers.

Add and subtract are by far the most arithmetic operations in programs, especially when including add and subtract of small constant values, which Thumb also gets all three operands (a = b +/- const) into 16 bits, provided const is less than 8. Other arithmetic such as boolean operations AND, OR, EOR shifts LSL, LSR, ASR, ROR and add and subtract with carry can only do a = a op b which means you will sometimes need to do a MOV a = c first, but they are not so common.

These restrictions are a bit annoying if you are programming in assembly language, where you like a very orthogonal instruction set, but compilers can easily deal with them.

Quote
The whole "compress a 32bit instruction into 16bits" thing is clever, but I wish it had been a less "lossy" compression.   The CM0 (with only 16bit thumb instructions) is pretty ugly

Ugh .. yes. Original Thumb was never intended to be the only instruction set available. There are so many system management things that aren't included at all, and even things such as 32x32->64 multiply.

Thumb2 is much nicer in that way, but because it was hacked in later it has an absolutely awful instruction encoding. I can understand 6502 programs quite well directly from a hex dump. Don't try to do that with Thumb2!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on August 04, 2017, 03:40:17 am
Add STM32F103RBT6 to the list too an M3 with huge benefits! :)

https://world.taobao.com/item/42883572952.htm?spm=a312a.7700714.0.0.6419a3bcVpjLuq#detail

Are GD32F103 CPUs on Taobao? I guess they are.. and probably a lot cheaper than STM32, maybe even < $1.

62 cents.

Though funny enough you can find STM32F103 for less... I think ST are effectively price dumping to keep that competition in check.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 06, 2017, 12:41:16 am
In case anyone was wondering if I ever got around to finishing this write-up, the answer is "Yes! Finally!"
 
Check out The Amazing $1 Microcontroller (https://jaycarlson.net/microcontrollers) on my blog.
 
It took several months of on- and off-again work, but I got through all 21 parts I selected.
 
I'd like to thank everyone on this thread for their help --- I got some excellent part recommendations --- but even better, I got feedback on some areas to focus on, too.
 
If there are things you think need to be mentioned that I'm forgetting, please drop a line on this thread (or, shamelessly plugging my blog, as a comment on this post  :))
 
Thanks again for the wonderful discussions!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 06, 2017, 01:23:20 am
In case anyone was wondering if I ever got around to finishing this write-up, the answer is "Yes! Finally!"
 
Check out The Amazing $1 Microcontroller (https://jaycarlson.net/microcontrollers) on my blog.
 
It took several months of on- and off-again work, but I got through all 21 parts I selected.
 
I'd like to thank everyone on this thread for their help --- I got some excellent part recommendations --- but even better, I got feedback on some areas to focus on, too.
 
If there are things you think need to be mentioned that I'm forgetting, please drop a line on this thread (or, shamelessly plugging my blog, as a comment on this post  :))
 
Thanks again for the wonderful discussions!
Holy crap that must have been a huge amount of work!
One thing I noticed - in the ISR latency figures, the PIC32MM came in quite high - was this using the shadow register bank ? (They annoyingly left this off the 32MX1xx devices, but makes a big difference where you have a high interrupt rate). 
This is not especially well documented, and ISTR there's a non-obvious register setting (PRISS) that needs setting as well as the IPLxSRS attribute in the ISR declaration.

One other point under "Usual Microchip advantages", though not a property of the chip per se, can be very relevant when looking at overall cost and conveneience  - low-cost preprogramming service via MicrochipDirect - I think some of the Atmel parts are also available on the service now.  For the smaller chips it's just a few cents to program, mark and re-reel.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 06, 2017, 01:42:45 am
One thing I noticed - in the ISR latency figures, the PIC32MM came in quite high - was this using the shadow register bank ? (They annoyingly left this off the 32MX1xx devices, but makes a big difference where you have a high interrupt rate). 
This is not especially well documented, and ISTR there's a non-obvious register setting (PRISS) that needs setting as well as the IPLxSRS attribute in the ISR declaration.
Wow — I had no idea this was a thing. I'll look into this at some point in the future and get back to you — otherwise, feel free to submit a pull-request (all the code is over on GitHub (https://github.com/jaydcarlson/microcontroller-test-code)) if this is an easy change.

One other point under "Usual Microchip advantages", though not a property of the chip per se, can be very relevant when looking at overall cost and conveneience  - low-cost preprogramming service via MicrochipDirect - I think some of the Atmel parts are also available on the service now.  For the smaller chips it's just a few cents to program, mark and re-reel.
This is a good point! Though, from my experience, basically everyone does this these days — at least the vendors I've used on recent volume products.

I think Microchip was one of the first, though — I'm almost positive I mention that somewhere buried deep in the PIC16 review, I think.

Thanks for the feedback!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on November 06, 2017, 01:54:47 am
Check out The Amazing $1 Microcontroller (https://jaycarlson.net/microcontrollers) on my blog.
A lot of good work has gone into producing that page. A key issue I see is how you determined relative pricing. 100 is such a low number that it really skews your impression of relative pricing. At the 100 level prices are almost random. You might have seen a saner set of relative prices if you had used, say, widely published 10k prices. Those are still not always representative of what a little negotiation or a higher volume might get you, but at least it gets you away from the silly prices you get at the 100 level.

If a part looks rather expensive compared to its competition you are either missing is special qualities, or seeing the wrong price. Seriously overly expensive parts seldom reach the market.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 06, 2017, 01:57:28 am
One thing I noticed - in the ISR latency figures, the PIC32MM came in quite high - was this using the shadow register bank ? (They annoyingly left this off the 32MX1xx devices, but makes a big difference where you have a high interrupt rate). 
This is not especially well documented, and ISTR there's a non-obvious register setting (PRISS) that needs setting as well as the IPLxSRS attribute in the ISR declaration.
Wow — I had no idea this was a thing. I'll look into this at some point in the future and get back to you — otherwise, feel free to submit a pull-request (all the code is over on GitHub (https://github.com/jaydcarlson/microcontroller-test-code)) if this is an easy change.
This is declared in the ISR handler as :

void __ISR(_UART2_RX_VECTOR,IPL7SRS)  uartint(void)

And you also need to tell it which int priority uses the SRS :
PRISS=0x10000000; //ipl7 use SRS1

I don't know if Microchip's code-gen stuff supports this as I have a pathological hatred of all manufacturer-supplied libraries, code generators etc. due to having spent way too much time tracking down bugs in them, or spending more time figuring out how to use them than it would have taken to just RTFDS and do it manually!


Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 06, 2017, 02:06:53 am
Quote
One other point under "Usual Microchip advantages", though not a property of the chip per se, can be very relevant when looking at overall cost and conveneience  - low-cost preprogramming service via MicrochipDirect - I think some of the Atmel parts are also available on the service now.  For the smaller chips it's just a few cents to program, mark and re-reel.
This is a good point! Though, from my experience, basically everyone does this these days — at least the vendors I've used on recent volume products.
I think Microchip was one of the first, though — I'm almost positive I mention that somewhere buried deep in the PIC16 review, I think.
Microchip are unusual in that they are one of the few ( only?) MCU makers who supply direct in smaller quantities, so programming is a simple add-on to that.
 Some distributors offer programming, but there can be issues like prohibitive cost ( especially for smaller parts where it can cost more than the part), limited part/package coverage, and stupid export control issues ( Digikey won't ship programmed parts outside the US as they don't know if the code implements export-controlled encryption etc.) 
I don't know of any other supplier where you can set up programming jobs and order parts online with a fairly low MOQ ( ISTR it's either 150 parts or $150  value), and get them in a few days.   
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on November 06, 2017, 02:49:55 am
Microchip are unusual in that they are one of the few ( only?) MCU makers who supply direct in smaller quantities, so programming is a simple add-on to that.
If you want pre-programmed devices done well, you want them programmed during assembly and test. If they are programmed later, SO, QFP and other packages with flimsy legs show a substantially increased rate of defects due to bent legs. It appears Microchip have set themselves up to do this for modest volumes. Most people only do it for serious volumes. I think pretty much any supplier of flash MCU will program them at the factory when you buy millions.
Some distributors offer programming, but there can be issues like prohibitive cost ( especially for smaller parts where it can cost more than the part), limited part/package coverage, and stupid export control issues ( Digikey won't ship programmed parts outside the US as they don't know if the code implements export-controlled encryption etc.) 
Don't forget that increased defect rate. It hits some people quite hard. If you can't get things programmed at the factory its best to program them after board assembly, to minimise the handling steps.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: NorthGuy on November 06, 2017, 03:41:23 am
Interesting review.

IMHO, instead of comparing CPU frequencies, then comparing toggle rates in cycles, it would be more useful to compare toggle rates in real-time terms (in us).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: EEVblog on November 06, 2017, 07:16:57 am
EPIC amount of work!  :-+  :clap:

https://jaycarlson.net/microcontrollers/
Title: Re: $1 MCU review — looking for part suggestions!
Post by: jaromir on November 06, 2017, 10:46:07 am
Now that's massive amount of work put into this preview. Looks like it's popular, your server is unavailable at times in last few hours.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 06, 2017, 11:19:30 am
Quote
UARTs with FIFOs in this test had significantly higher interrupt latencies than UARTs without FIFOs.
..er isn't that kinda the point of a FIFO'd UART?
 or do you mean they have worse latency when the FIFO is disabled/set to minimum?
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 06, 2017, 11:32:15 am
or do you mean they have worse latency when the FIFO is disabled/set to minimum?
I meant that first-byte ISRs with the FIFO enabled seem to have slightly worse latency (a few cycles) than ISRs from regular, FIFOless UARTs.

ISR latency is caused by prologue code (especially heavy on stack-based parts like AVR and Arm), core design, but also peripherals. From my testing, it looks like a lot of parts with FIFOs had additional ISR latency when compared to parts without FIFOs (of course, I'm assuming the ISR is set to trigger on the first byte received). I mostly used the FIFO functionality to slow down the core — sitting in a while() loop, processing FIFO bytes is a lot faster than exiting and re-entering the ISR.

Keep in mind that I didn't do what you usually do with FIFOs — set up an ISR to trigger after they're already full. This was mainly because many FIFOs had strange policies when it came to bytes received with framing errors (which is what I use to detect the start of frame for DMX-512).

I suspect the FIFO-enabled UARTs have a bit more register transfer stuff they have to do, which ends up adding in a few extra cycles before they can assert the interrupt signal — but that's just a guess.

I'm comparing among the Arm parts, which all have the same core and should have relatively similar prologue code before hitting the register (this second assumption might not be entirely true, though, now that I think about it).

There's better ways to isolate and test for this (with "naked" declarations for the ISRs), and admittedly I didn't have time to do this.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 06, 2017, 11:48:41 am
This was mainly because many FIFOs had strange policies when it came to bytes received with framing errors (which is what I use to detect the start of frame for DMX-512).
Oh, yeah, been there, done that!
Definitely something you need to test as it's rarely mentioned in the datasheet.
ISTR some particularly fun times with a NXP part that had seperate ints for UART receive and UART errors, which only manifested with one Artnet device that put the break immediately after the last byte, so it ended up somewhere in the FIFO.
Latency on a FIFO's UARTs is very rarely an issue in practice - what I find more annoying is UARTs like the PIC32 which don't have a timeout mechanism to empty the FIFO at the end of a burst of data, so you end up needing to dedicate a hardware timer to do it.
 
 
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mariush on November 06, 2017, 11:49:49 am
For those impatient, looks like there's an archive.org copy of the long article / website here :  https://web.archive.org/web/20171106070102/https://jaycarlson.net/microcontrollers/
Title: Re: $1 MCU review — looking for part suggestions!
Post by: JPortici on November 06, 2017, 11:51:52 am
Amazing :D
I have some render issues though (firefox 56.0.2 under win 7 pro, 1920x1080p)

as a long time PIC afficionado i'll make one note for the article:
for the PIC18F, the "K" series is the one which is actually being developed. the K42 and K83 families (the most recents, came out this year) are the real BEASTS in terms of PIC18 (DMA, vectored interrupt, fully routable PPS, more memory, 12 bit adc with good ENOB, channel scan, digital filters etc., the K83 also has CAN compared to the K42)

(and of course everything is pin-to-pin compatible between families.. from different PIC16s up to dsPICs, but with some minor adjustments from 8bit to 16 bit  :blah: :blah: :blah:)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ali_asadzadeh on November 06, 2017, 01:01:13 pm
It's a big thumbs up, I think you should have added the 1$ cortex M3 parts like STM32F103RBT6 to the list too, it would be more fair then ;) :)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: donotdespisethesnake on November 06, 2017, 01:03:22 pm
In case anyone was wondering if I ever got around to finishing this write-up, the answer is "Yes! Finally!"
 
Check out The Amazing $1 Microcontroller (https://jaycarlson.net/microcontrollers) on my blog.

Great report! And nicely presented too. The overall impressions are similar to what I have got from personal experience or reading other people's experiences. It would be nice to see a ranking by price, even if rough/relative guidance. I have reasonable flexibility to select parts based on dev tools, IDE etc, but price is the #1 for the operations manager.

A couple very minor typos "choke-full" => "chock-full", "weary" => "wary", although the homophones are appropriate too.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: NorthGuy on November 06, 2017, 04:08:06 pm
ISR latency is caused by prologue code (especially heavy on stack-based parts like AVR and Arm), core design, but also peripherals.

Prologue code is 80% (if not more) of the latency. So, the latency measurements are mostly the measure of efficiency of C optimizations of the particular compiler. BTW: toggle times too, to certain degree, evaluate the C compiler quality.

The UART module, if it includes hardware FIFO between the receiver and the MCU core, will produce interrupt not when the character is received, but when it is placed into FIFO, which comes later. So, ideally, if you want to measure interrupt latency per se, you must start your measurement from FIFO (which is not really possible).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Boscoe on November 06, 2017, 05:11:34 pm
Someone might have already posted this...

https://jaycarlson.net/microcontrollers/
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Howardlong on November 06, 2017, 09:26:42 pm
Congratulations on such a huge undertaking!

I noted that you included a Code Generator section. Do folk really use these for production code? OK, when you need to use complex peripherals, like USB, for some devices it’s the only thing the vendor offers, but for more mundane peripherals like SPI, I2C, UARTs, PWM, really? You’re going to have to understand the device at the peripheral register and hardware level anyway, so what value do they add perhaps beyond short term instant gratification?

The two I have the most experience with by a long chalk are Microchip’s MHC and MCC. Both are bug ridden, and both make code incredibly difficult to maintain as the programmer’s business logic (and code genrator bug fixes) are mixed in with the generated code. So if you change, say, a pin assignment, it regenerates the code and you risk it stamping all over your own code. Moving between versions often means you have to start from scratch too. I also despise the proprietary straightjacket directory and file structure it places you under.

Maybe others have better experiences of Code Generators than I do?
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on November 06, 2017, 09:50:03 pm
I'm wondering why there is so much difference between the performance of STM32F0 and the LPC811. Given the small difference in clock frequency I'd expect them to be much closer. Is this due to compiler optimisation perhaps? What would be an interesting addition to this test is a comparison of code density and speed between the various compilers.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: dgtl on November 06, 2017, 10:31:15 pm
An awesome work! Thank you!

Not being a fanboy of PSOC myself, I tried to implement the 1wire master in UDBs in my spare time and went low-level on PSOC. Actually, the registers datasheet is public ("Register TRM", about 5500 pages!) and the bitstream is actually just an array of registers, not a black box. Getting to the bottom of it to understand what is where took about 1 week of evening reading. Each UDB has some registers in the configuration space and some in runtime space. But this is so complex, that the uc would be of very little use without the psoc creator software, developing on that without tools would be a nightmare. Also, the definitions of the runtime registers depend on the configuration set up at boot and thus the register datasheet is quite useless without decoding the inner workings of the generated peripherals (simple for SCB, a lot of reverse engineering for UDB). In addition, nothing stays put in that chip, things can be re-routed differently and absolute addresses are useless; at least have to use the auto-generated defines made by the placer. All in all, pretty useless going low level unless there is a niche application, that needs some kind of tricky interface and FPGA would be too large.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 06, 2017, 10:48:21 pm
I'm wondering why there is so much difference between the performance of STM32F0 and the LPC811. Given the small difference in clock frequency I'd expect them to be much closer. Is this due to compiler optimisation perhaps? What would be an interesting addition to this test is a comparison of code density and speed between the various compilers.
In my testing, I discovered the big problem with the LPC811 is the lack of a flash accelerator/caching mechanism (or if it has one, it's not very good). Flash memory for these parts typically tops out at 25 MHz, so the nice 48 MHz Arm parts all have good caching capabilities (IIRC, the SAM D10 and Kinetis KL03 were the best, but the STM32F0 did well, too).

If you ever want to see if that's what's going on, reduce your core clock speed and count cycles — if your code magically takes fewer cycles at slower clock speeds, look at flash wait-states.

The higher-end LPC parts are lovely to work with — but I was stuck reviewing bottom-of-the-barrel parts due to the $1 price constraint. I like MCUXpresso a lot, and the NXP folks are helpful to work with — especially for start-ups/small players. I just wish they had some better entry-level parts.

Infineon, for what it's worth, has equally-bad (if not worse) flash-constricted performance on the XMC1100 — but the part has 16 KB of RAM, so you can just decorate your ISRs and any other performance-critical work with "place in RAM" attributes, and you'll be running at full speed — and with excellent power consumption.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 06, 2017, 11:11:30 pm
Congratulations on such a huge undertaking!
Thanks! Glad to see people are learning and starting conversations from it.

I noted that you included a Code Generator section. Do folk really use these for production code? OK, when you need to use complex peripherals, like USB, for some devices it’s the only thing the vendor offers, but for more mundane peripherals like SPI, I2C, UARTs, PWM, really? You’re going to have to understand the device at the peripheral register and hardware level anyway, so what value do they add perhaps beyond short term instant gratification?
In my experience, I see start-ups and R&D teams using code generators all the time, because they're not an "Atmel shop" or an "Infineon shop" — and, for small-volume or R&D work, code generators let you get quick access to the stuff you selected the part for (say, the PIC16's NCO/CLC stuff), without having to futz around with UART baud-rate generator settings and clock-gating. This is especially true in the 32-bit space.

When engineering consultants can cost a company north of $200/hr, do you really want to pay an engineer to sit around and read datasheets, or do you want to use a slightly faster part that allows them to quickly build up the demo for the investors meeting?

The two I have the most experience with by a long chalk are Microchip’s MHC and MCC. Both are bug ridden, and both make code incredibly difficult to maintain

I had admittedly limited surface-area contact with the code-gen tools in my review, but I didn't notice any outright bugs in the generated code for my DMX-512 receiver, which has to do UART, PWM, and any secondary function (pin muxing, clock gating, timer init, etc).

There are some design decisions I would probably change, but that's a give-and-take that different vendors land on.

The biggest bugs were with Atmel START on the SAM D10 — which didn't provide any modicum of error-checking, and statically displayed a "48 MHz" label under the DFLL, regardless of what it was actually configured to use.

As for the "hard to maintain" argument, the best code-gen tools had no issues with this. For example, Silicon Labs' Simplicity Configurator has no problems adding/modifying/removing ISRs in the same files that had my custom code. ST and Renesas, too --- albeit they cheat a bit and have comment blocks that define precise locations where you can and cannot put user code.

The worst offenders for what you were talking about were probably Microchip and Atmel — their code-gen tools seem incapable of merging their changes with custom-written code.

It sounds like you have experience with Microchip; one of my goals of this review is to illustrate how other ecosystems work, so people don't accidentally generalize their understanding of a function across every possible product line.

For what it's worth, the most efficient (in terms of speed and/or flash) code for the DMX-512 receiver was generated by code-gen tools, compared to those from just standard runtime peripheral libraries.

Intuitively, it seems to make sense: runtime libraries have to calculate a bunch of crap that's known at compile time. Theoretically, the optimizer should be able to get in there and eliminate a bunch of that stuff, but in practice, this doesn't happen as much as you'd think.

A code-gen tool that just spits out a bunch of raw register writes in an init function for a UART is always going to beat a run-time UART initialization library that calculates baud-rate generator registers on the fly, for example.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: HwAoRrDk on November 07, 2017, 12:00:08 am
This guide is awesome. Thank you! :-+

I spent a couple of hours today reading. I'm definitely going to come back to this next project I do needing an 8-bit MCU.

By the way, I noticed a problem with the standard peripheral library code example on the STM8 page (https://jaycarlson.net/pf/st-stm8/). It has HTML mixed into the code in a couple of places, e.g.:

Code: [Select]
  while (!I2C_CheckEvent(I2C_EVENT_MASTER_ADDRESS_ACKED));
  I2C_ClearFlag(I2C_FLAG_ADDRESSSENTMATCHED);
  I2C_SendData<sup id="footnote_plugin_tooltip_1" class="footnote_plugin_tooltip_text" onclick="footnote_moveToAnchor('footnote_plugin_reference_1');">1</sup><span class="footnote_tooltip" id="footnote_plugin_tooltip_text_1">u8)(ReadAddr >> 8</span>%MINIFYHTML9299bf39575ecf70dee23834ee18551524%; /* MSB */
  while (!I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED));

Looks like your footnotes plug-in has run amok.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: funkathustra on November 07, 2017, 12:17:29 am
Looks like your footnotes plug-in has run amok.
Nice catch! Fixed; should be pushed out soon.

I thought the (( )) footnote parsing syntax was too good to be true, and now I know...
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on November 07, 2017, 06:22:26 am
Quote
Thanks! Glad to see people are learning and starting conversations from it.
Indeed.  This is a much more impressive result than what I was expecting from the initial discussions!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: donotdespisethesnake on November 07, 2017, 09:55:44 am
It's a big thumbs up, I think you should have added the 1$ cortex M3 parts like STM32F103RBT6 to the list too, it would be more fair then ;) :)
They are only $1 in Shenzen... Typical western SMEs are ordering large volumes via reputable distributors such as Avnet, Arrow etc, smaller volumes from Digikey, Mousers (or national equivalent). Ordering via AliExpress or Taobao for production stock is simply not an option for the companies I work for.

The code is available, you can always port it to a STM32F103 board and create a report. It would be interesting to know how much an M3 buys over a M0. My suspicion is that M0 is just a market positioning to compete with 8 bitters, if you take an M3 and run it at lower clock speeds it will be nearly identical to an M0 in terms of performance and power consumption. I understand the license fees to silicon vendors for M0 core design are ridiculously cheap.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: tszaboo on November 07, 2017, 10:40:56 am
It would be interesting to know how much an M3 buys over a M0.
Under the hood, there are huge differences between M0 and M3.
For example M0 is Neumann architecture, M3 is Harvard.
M0 has 2 stage pipeline M3 has 3 stage, and their DMIPS is like 1.5 times higher.
Sure, this doesnt matter for flipping bits and sending stuff through UART, because if that is all you do, then it is easy, just use an M0.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Whales on November 07, 2017, 10:50:00 am
My light hobbyist foray into the micro world scarred me.  Expensive programmers and crazy toolchains.  I expected everything to be supported by GCC and programmable via a simple protocol atop UART. 

Haha. Ha. Ha.  Avrdude you have spoiled me.

I now want to try one of those STC8's :D   8051 sounds like a nice option simply because of the interchangeability.  I'll also give LCSC a go.

funkathustra: thankyou for your investigations and your writeup.  I've previously looked for 8051 parts and only found ancient low-stock microprocessors.  You have cleared several clouds for me.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: josip on November 07, 2017, 01:53:07 pm
funkathustra,

BTW, all MSP430 FRAM devices are with 20-bit CPUXv2, with some 20-bit / 1 cycle (address) assembler instructions. They are also limited by FRAM wait states, but code can be copied to RAM and executed at full speed.

I didn't noticed on your (remarkable) page any data regarding flashing erase/write rate. It is more comfortable to work with devices with faster operations, and there is significant difference between vendors. For example, some reference can be found here...
https://www.segger.com/products/debug-probes/j-link/technology/flash-download/#tab-3145-1 (https://www.segger.com/products/debug-probes/j-link/technology/flash-download/#tab-3145-1)   
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Howardlong on November 07, 2017, 03:10:21 pm

A code-gen tool that just spits out a bunch of raw register writes in an init function for a UART is always going to beat a run-time UART initialization library that calculates baud-rate generator registers on the fly, for example.

I think my favourite method would be for these code generators to just give me a set of code on demand that I can copy and paste into _my_ directory and file structure, not theirs. I don't see any value in being nanny-stated into a generic "framework" which will always be a compromise, being too complex for simple projects, and unnecessarily prescriptive for larger ones.

A code generator that dictates a framework must be able to manage and separate clearly between user code and its own code, and deal with bug fixes to generated code, MCC doesn't do that well at all.

There are many bugs in MCC, the worst I've encountered was that it initialised a particular peripheral's registers in the wrong order. This is quite common, where you cannot legally change certain peripheral settings after it's been turned on, but the ON bit is one of the first things it sets. The particular scenario I had was a little more complex, but you get the gist. I'd also prefer that there was an option for the generator write code as bitfields or mask macros, rather than a series of opaque hex blobs that each might cover a dozen or so configuration parameters that are not easy to match up with the datasheet when you're trying to figure out why it doesn't work.

A particular problem that afflicts MCC is that newly adopted devices tend to be left to the community to test on behalf of Microchip, there rarely seems to be any testing of any sort done, it's not uncommon to be unable to even start the oscillator.

I had one a few days ago where it failed to disable the JTAG interface that was shared with a number of GPIOs I was using as status LEDs, as a demonstration for someone on how to use MCC, even though I'd warned against it. Had I written the code myself, this simply would not have happened, and even it had, I'd have had transparency and understanding rather than second guessing some half baked code.

Title: Re: $1 MCU review — looking for part suggestions!
Post by: MT on November 07, 2017, 03:33:15 pm
I recall every week there is at least one person reporting bugs created by Cube MX.

@funkathustra
Great report but the "timer points" dont reflect on timers ability to IRQ/DRQ which could be considered equally important as having a CC channel. F4 for instance are plagued by crappy IRQ/DRQ assignment which makes even simple DMA sequencing a pain and in many cases impossible (conflicting GPIO assignments and or Timers dont have DRQ at all or are assigned on the wrong DMA unit).

Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: josip on November 07, 2017, 07:33:15 pm
Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!

This is one of most important things to me. That any port /peripheral / analog signal can be routed to any device pin. And that one peripheral output (for example timer pwm) can be routed to multiple device output pins. Didn't  found vendor that support this on Cortex M0 / M0+ / M3 / M4 devices.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on November 07, 2017, 08:10:18 pm
Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!

This is one of most important things to me. That any port /peripheral / analog signal can be routed to any device pin. And that one peripheral output (for example timer pwm) can be routed to multiple device output pins. Didn't  found vendor that support this on Cortex M0 / M0+ / M3 / M4 devices.
NXP does on their LPC1500 series. Then again being able to route pins to any I/O is highly overrated. The pins which belong together are usually grouped anyway so if you think a bit about the PCB layout while drawing the schematic you can come up with a good component placement and thus easely routable PCB design.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: josip on November 07, 2017, 08:24:19 pm
NXP does on their LPC1500 series. Then again being able to route pins to any I/O is highly overrated. The pins which belong together are usually grouped anyway so if you think a bit about the PCB layout while drawing the schematic you can come up with a good component placement and thus easely routable PCB design.

No, it is not related to PCB layout. Let say that I am using one port (with 8 IO lines) in one short period of time like input/output, and in another short period of time as timer pwm output, and switching between two mods. I want to read / write with one assembler instruction from / to all 8 IO lines, not in 5 instructions because timer pwm outputs are distributed on 5 different ports (addresses). I am spoiled with TI MSP430F5xx family that have one port (8 lines) with all peripherals mapped on it. On TI MSP432 there are 3 ports (24 lines) with all peripherals mapped on it. Unfortunately, didn't found similar thing on low cost M0+/M3 from other vendors.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: nctnico on November 07, 2017, 08:41:37 pm
I still don't get why you can't solve your problem with carefully selecting the I/O lines. I know NXP ARM devices inside out and they have the I/O pins on a few ports which are packed with pins (except for the last port).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: thm_w on November 07, 2017, 10:12:23 pm
I recall every week there is at least one person reporting bugs created by Cube MX.

Its not that bad..
Title: Re: $1 MCU review — looking for part suggestions!
Post by: MT on November 07, 2017, 11:18:57 pm
Its not that bad..
Yes it is! Sometimes it's close to 3 bugs a week! :popcorn:
This is one of most important things to me. That any port /peripheral / analog signal can be routed to any device pin. And that one peripheral output (for example timer pwm) can be routed to multiple device output pins. Didn't  found vendor that support this on Cortex M0 / M0+ / M3 / M4 devices.
Recall the old F100 could have multiple peripherals on at the same time on same pin.

NXP does on their LPC1500 series. Then again being able to route pins to any I/O is highly overrated.
Overrated perhaps but with STM32 things arent even pin compatible per package, and the pin mapping is quite badily done, loads of peripherals conflicts with each other particularly timers.

Quote
The pins which belong together are usually grouped anyway so if you think a bit about the PCB layout while drawing the schematic you can come up with a good component placement and thus easely routable PCB design.
Unfortunately with STM32 thats not the case, many peripherals are spread out on all the sides just inviting for cross-talks and problematic layouts.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mikeselectricstuff on November 08, 2017, 06:32:52 am
Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!

This is one of most important things to me. That any port /peripheral / analog signal can be routed to any device pin. And that one peripheral output (for example timer pwm) can be routed to multiple device output pins. Didn't  found vendor that support this on Cortex M0 / M0+ / M3 / M4 devices.
Some of the more recent PIC8s ( e.g. 16F153xx) can also route any peripheral function to any pin.
This is an extremely useful feature, especially on 2-layer PCBs. PIC32MX isn't quite as flexible, but as there are multiples of most peripherals, between choosing which of the peripherals and the pin mapping you have a lot of flexibility.
From memory I think that on the 32MM, one of a pair of peripheral is fixed an the other is mappable to any pin.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: ebclr on November 08, 2017, 07:00:06 am
"Anything I'm missing? Thanks!"

https://direct.nuvoton.com

N76E885AT28
N79E715AS16
N76E885AT20
N79E715AT20
N79E715AT28
N76E616AL48
N76E003AT20
N79E8432ASG
Mini51FDE
Mini52FDE
Mini54FDE
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on November 08, 2017, 11:25:25 am
Another important factor are "pin routing ability" PIC24 excels STM32 in many cases for instance, even the F0 is quite crap at this. Just my 1/2 cent!
The presence of pin routing is mostly a matter of when the design started. Across the industry pin routing was quite limited, then suddenly it became flavour of the month to have extensive programmable pin routing. It doesn't cost much die area to add this to a fine geometry MCU, at least for digital pins which are not pushing any speed limits. Going forward I think you can expect this to be an almost universal feature for lowish speed digital peripheral pins.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: tszaboo on November 08, 2017, 01:03:12 pm
Unfortunately with STM32 thats not the case, many peripherals are spread out on all the sides just inviting for cross-talks and problematic layouts.

While I quite like the ST microcontrollers, it is an absolute nightmare to route them. For example an SPI port can be on 3 sides of the micro. Going to an ADC, and driving it with 20-40MHz clock. Or there was one time, probably the last, when I routed a SRAM into a ST micro part. All 4 sides. Criss-crossing with the Ethernet controller RMII lines, and the USB. For some reason, on a 4 layer board, we couldn't run the SRAM at the advertised speed. I wonder why.
And the 32F103. OK it has USB and CAN. I designed the board, so it uses both of them. They are on the same pins, but you can re-map the CAN. So no problems, rigth? Well the firmware programmer found hidden on page 15894 of the reference manual, in the footnote in brackets with smaller font size, that:
(*Ah, yes, BTW the USB and the CAN are using the same memory space for some reason. They cannot be used at the same time. Sucks to be you!)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: cv007 on November 08, 2017, 07:45:14 pm
Quote
Some of the more recent PIC8s ( e.g. 16F153xx) can also route any peripheral function to any pin
They still do have port restrictions on the higher pin count devices- like a 28pin 16F18854 for example each in/out peripheral will be restricted to 2 of the available ports (it varies which 2). Which still is quite good.  It is a very nice feature to have (and probably necessary with the many peripherals they have on these newer devices).

Another nice piece of info to have with these micro comparisons, is the source/sink current per pin and totals.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: technix on November 09, 2017, 06:49:54 pm
Since you mentioned STC, the STC15W100 I’m SO-8 is close to 10 US cents each (12?)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: JPortici on November 09, 2017, 07:00:56 pm
Another nice piece of info to have with these micro comparisons, is the source/sink current per pin and totals.

i am FINALLY evaluating the 18F K42 series. The ADC is impressive but has some quirks i haven't understood (i wish it had channel scan tho). The PPS is a blessing. Many other new peripherals since the K22 are so ugggh, awesome.
And if you need that, programmable drive strenght and current source-sink per pin or per port (i don't have the datasheet open)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: igendel on November 10, 2017, 12:40:32 pm
Hey everyone! I'm reviewing $1 (@ 100 QTY) general-purpose 8/16/32-bit MCUs from a wide range of vendors

Well, I'm reading the review now (it was published on the "Microchip Makes" facebook page) and it's fascinating. Excellent work!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on November 11, 2017, 03:26:10 am
Really amazing review, I'm in awe of the amount of work you put into it! Definitely a resource I will recommend to others.

Since you mentioned STC, the STC15W100 I’m SO-8 is close to 10 US cents each (12?)

Is it? On taobao I'm seeing pricing between 1.2-2RMB (indicative of course, but works as a first approximation).
Nuvoton N76E003AT20, a part pin-compatible to the stm8s003f3p6, is showing for 0.76-1RMB (I just asked one of the shop keepers, they're fine with selling 10 at 0.76RMB, around $0.11 currently... 9 for $1  ;D).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: janekm on November 11, 2017, 06:29:21 am
Really amazing review, I'm in awe of the amount of work you put into it! Definitely a resource I will recommend to others.

Since you mentioned STC, the STC15W100 I’m SO-8 is close to 10 US cents each (12?)

Is it? On taobao I'm seeing pricing between 1.2-2RMB (indicative of course, but works as a first approximation).
Nuvoton N76E003AT20, a part pin-compatible to the stm8s003f3p6, is showing for 0.76-1RMB (I just asked one of the shop keepers, they're fine with selling 10 at 0.76RMB, around $0.11 currently... 9 for $1  ;D).

Actually I have to take that back... the shop was gaming the taobao search by applying a discount on single quantities, which reduces the more you buy. I think that's the first time I've seen a negative quantity discount ;) 10 pieces ended up costing 1.07RMB each. 1 would have been 0.76.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: technix on November 11, 2017, 12:59:03 pm
Really amazing review, I'm in awe of the amount of work you put into it! Definitely a resource I will recommend to others.

Since you mentioned STC, the STC15W100 I’m SO-8 is close to 10 US cents each (12?)

Is it? On taobao I'm seeing pricing between 1.2-2RMB (indicative of course, but works as a first approximation).
Nuvoton N76E003AT20, a part pin-compatible to the stm8s003f3p6, is showing for 0.76-1RMB (I just asked one of the shop keepers, they're fine with selling 10 at 0.76RMB, around $0.11 currently... 9 for $1  ;D).

Actually I have to take that back... the shop was gaming the taobao search by applying a discount on single quantities, which reduces the more you buy. I think that's the first time I've seen a negative quantity discount ;) 10 pieces ended up costing 1.07RMB each. 1 would have been 0.76.
You need to source them directly from STC to get the prices right.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: FrankBuss on November 11, 2017, 01:51:20 pm
Also, don't forget those Taiwanese OTP MCUs targeting white appliances. Some Holtek and Elan MCUs may be down to a few cents.
Those unpackaged OTP bare dice may be even cheaper (the ones found in Chinese toys).
They typically require NDA and expensive compiler software and programmer hardware, but running cost for mass production is super ultra cheap.

I wonder how much an ATTiny9 would cost in larger quantities. At Digikey you can get it for 24 cent (https://www.digikey.de/short/q37fhc) if you buy 100. And I guess it can do more than some ultra cheap OTP MCUs. At least it is powerful enough to do realtime audio synthesis for playing a chiptune (https://plus.google.com/+FrankBussProgrammer/posts/Q9zRGZi8Sfr).
Title: Re: $1 MCU review — looking for part suggestions!
Post by: Siwastaja on November 11, 2017, 02:37:00 pm
The Renesas RL-78 is one of the best MCUs in this price range (considering performance and power consumption), has fantastic free dev tools, and it's virtually unheard of in the U.S.
But if you do have a problem, good luck getting any support. Manufacturer will not respond unless you are buying millions, and there is no public support, since nobody uses them in hobby and small scale projects.

Okay, so Renesas won't help you, so how about others?

My experience with STM32 is that if you really need support, you won't get any.

Sure, if you are a total beginner and need to see a copypaste of an example code how to get a LED blinking, you'll get it from the forums. They are great for that.

With any real problem, you are on your own.

For example, when reporting a non-documented silicon bug and asking how to proceed from there, even as a business customer, ST just ignores you.

And ST is one of the most used and well known players on the ARM market, STM32 being a well known brand.

I guess it's the same game with everyone, really. We just have the feeling of "having support" when we work with the "well known" names, whereas in reality, we can only help ourselves. Starting from the risk that we never know if some part will be available tomorrow or not.

--


Quality of documentation and the exactness of it (i.e., is the product working within spec sheet / reference manual?) is, IMO, one of the most important criteria. Even a slightly poor choice of words can easily cost 10 hours of engineering time due to confusion and wrong assumptions. An omission of a small detail may cost another 10 hours. A copy-paste error or a typo is 10 hours more, then a undocumented silicon bug eats 50 hours extra. These do add up, this is typical design flow with STM32 in my experience.

Unfortunately, this is very time-consuming to evaluate. You'll know once you have fully stepped in and done full designs with said chips. And at that point, you consider yourself an experienced designer on said architecture, don't want to try anything else, since you already have "won" the battle and fear that another product family will bring you back to square one again.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: mrcrud5 on November 24, 2017, 12:44:27 pm
This post got a shout out on the amp hour!
Title: Re: $1 MCU review — looking for part suggestions!
Post by: coppice on November 24, 2017, 12:56:07 pm
Also, don't forget those Taiwanese OTP MCUs targeting white appliances. Some Holtek and Elan MCUs may be down to a few cents.
Those unpackaged OTP bare dice may be even cheaper (the ones found in Chinese toys).
They typically require NDA and expensive compiler software and programmer hardware, but running cost for mass production is super ultra cheap.
Expensive compiler software and programmer hardware is an interesting industry dynamic. When the required tools are rather expensive they are such an impediment to sales that they typically get "loaned" to serious high volume developers. Of course, their useful life is not that great, as the target devices become obsolete quite quickly, so the "loaned" items never really go back to the vendor at the end of projects. For the developer, those "expensive" tools cost less than a simple JTAG gadget for programming a flash MCU.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: technix on November 25, 2017, 09:28:09 am
Also, don't forget those Taiwanese OTP MCUs targeting white appliances. Some Holtek and Elan MCUs may be down to a few cents.
Those unpackaged OTP bare dice may be even cheaper (the ones found in Chinese toys).
They typically require NDA and expensive compiler software and programmer hardware, but running cost for mass production is super ultra cheap.
Expensive compiler software and programmer hardware is an interesting industry dynamic. When the required tools are rather expensive they are such an impediment to sales that they typically get "loaned" to serious high volume developers. Of course, their useful life is not that great, as the target devices become obsolete quite quickly, so the "loaned" items never really go back to the vendor at the end of projects. For the developer, those "expensive" tools cost less than a simple JTAG gadget for programming a flash MCU.
That is kind of a barrier keeping individual hackers out of their ecosystem, and locking existing customers in.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on December 06, 2017, 01:59:01 am
I'm currently trying to resist buying a bunch of < $0.25 Freescale S09 chips that Newark is flushing...  Sigh.
Title: Re: $1 MCU review — looking for part suggestions!
Post by: technix on December 06, 2017, 08:26:02 am
I'm currently trying to resist buying a bunch of < $0.25 Freescale S09 chips that Newark is flushing...  Sigh.
What are those? And how do you program them?
Title: Re: $1 MCU review — looking for part suggestions!
Post by: FrankBuss on December 06, 2017, 10:29:12 am
$0.25 is expensive. You can get an ATTiny5 for $0.20 at Digikey (https://www.digikey.com/short/qq7ddd), and $0.168 if you buy 100. But the flash size is very small. If you pay $0.35, you can get an ATTiny9, which can be used to play a chiptune:

https://www.youtube.com/watch?v=ycfYZpyQRzw (https://www.youtube.com/watch?v=ycfYZpyQRzw)
Title: Re: $1 MCU review — looking for part suggestions!
Post by: westfw on December 06, 2017, 08:47:07 pm
Quote
Quote
trying to resist buying a bunch of < $0.25 Freescale S09 chips that Newark is flushing.
What are those? And how do you program them?

Oh, like ($0.05): http://www.newark.com/nxp/mc9rs08kb2csc/microcontroller-mcu-8-bit-rs08/dp/29R0568 (http://www.newark.com/nxp/mc9rs08kb2csc/microcontroller-mcu-8-bit-rs08/dp/29R0568)
Or ($0.08): http://www.newark.com/nxp/mc9s08qd4msc/microcontroller-mcu-8-bit-s08/dp/22M5768 (http://www.newark.com/nxp/mc9s08qd4msc/microcontroller-mcu-8-bit-s08/dp/22M5768)
(There are more <$0.20, but the "sort" function doesn't recognize "special" prices...)

If I understand the history right, the HC08 is an enhancement of the old 6805 (which was a "microcontroller oriented) 6800?), the S08 is a modernized version of that, and the RS08 is a "reduced" S08 (rather unpleasantly: looks like 1 level of subroutine "stack"!)  They're 8-bit accumulator/memory architecture with index register; rather CISCy.  You can still download free "Codewarrior for microcontrollers" that has "unlimited assembler" and "C compiler with irrelevant restrictions for those chips" (though I'm not sure how that'd work for the RS08!)
Something like "high voltage serial programmer" and or "Background Debug Mode" (both documented and with some Open Source implementations.)
While accumulator architectures are out-of-style, the old motorola implementations were supposed to be "pretty good", and these aren't yet actually "discontinued" (though they're not too cheap "normally"), so you could do worse in a search for ultra-cheap jellybean microcontrollers for trivial applications.  (And I have.  Anybody want some OTP Toshiba 4-bit microcontrollers?  :-(  The whole "these things can't be THAT hard to use" feeling is an illusion.  Thus my attempt to "resist.")
Title: Re: $1 MCU review — looking for part suggestions!
Post by: technix on December 07, 2017, 10:07:15 am
Quote
Quote
trying to resist buying a bunch of < $0.25 Freescale S09 chips that Newark is flushing.
What are those? And how do you program them?

Oh, like ($0.05): http://www.newark.com/nxp/mc9rs08kb2csc/microcontroller-mcu-8-bit-rs08/dp/29R0568 (http://www.newark.com/nxp/mc9rs08kb2csc/microcontroller-mcu-8-bit-rs08/dp/29R0568)
Or ($0.08): http://www.newark.com/nxp/mc9s08qd4msc/microcontroller-mcu-8-bit-s08/dp/22M5768 (http://www.newark.com/nxp/mc9s08qd4msc/microcontroller-mcu-8-bit-s08/dp/22M5768)
(There are more <$0.20, but the "sort" function doesn't recognize "special" prices...)

If I understand the history right, the HC08 is an enhancement of the old 6805 (which was a "microcontroller oriented) 6800?), the S08 is a modernized version of that, and the RS08 is a "reduced" S08 (rather unpleasantly: looks like 1 level of subroutine "stack"!)  They're 8-bit accumulator/memory architecture with index register; rather CISCy.  You can still download free "Codewarrior for microcontrollers" that has "unlimited assembler" and "C compiler with irrelevant restrictions for those chips" (though I'm not sure how that'd work for the RS08!)
Something like "high voltage serial programmer" and or "Background Debug Mode" (both documented and with some Open Source implementations.)
While accumulator architectures are out-of-style, the old motorola implementations were supposed to be "pretty good", and these aren't yet actually "discontinued" (though they're not too cheap "normally"), so you could do worse in a search for ultra-cheap jellybean microcontrollers for trivial applications.  (And I have.  Anybody want some OTP Toshiba 4-bit microcontrollers?  :-(  The whole "these things can't be THAT hard to use" feeling is an illusion.  Thus my attempt to "resist.")
Well it is likely that if I ever want to build anything around those I will first need to build myself the programmer and debugger hardware. It is good that my computer actually still had a Super I/O ISA parallel port available but how to get it to show up in macOS... Just like my 8051 boards which is stuck in a dev tool limbo.

Maybe I have to stick to STM32 and other ARM for a while.